Connecting Tech Pros Worldwide Forums | Help | Site Map

Time convert problem

Ralf Meuser
Guest
 
Posts: n/a
#1: Jul 17 '05
Hi there,

I get form a database time with the format : 'Jan 01 1900
06:00PM'

I want to convert it to :HH:MM
I tryed it with $heure=(date("H:i",strtotime($row[0]))
but I get allways 20:55. even when time changes. Whats wrong ?

Does anybody know where I can get a good function which will convert date to
date and time to time with different formats ?

Thanks in advance for any help

Best regards

Ralf




Alistair Baillie SS2002
Guest
 
Posts: n/a
#2: Jul 17 '05

re: Time convert problem


its because its not a php timestamp.

A quick search of google, revealed this;

http://php.codenewbie.com/articles/p...mp-Page_1.html

- Ali

"Ralf Meuser" <rmeuser@free.fr> wrote in message
news:426f7e2c$0$25552$636a15ce@news.free.fr...[color=blue]
> Hi there,
>
> I get form a database time with the format : 'Jan 01 1900
> 06:00PM'
>
> I want to convert it to :HH:MM
> I tryed it with $heure=(date("H:i",strtotime($row[0]))
> but I get allways 20:55. even when time changes. Whats wrong ?
>
> Does anybody know where I can get a good function which will convert date
> to date and time to time with different formats ?
>
> Thanks in advance for any help
>
> Best regards
>
> Ralf
>
>
>[/color]


Colin McKinnon
Guest
 
Posts: n/a
#3: Jul 17 '05

re: Time convert problem


Ralf Meuser wrote:
[color=blue]
> Hi there,
>
> I get form a database time with the format : 'Jan 01 1900
> 06:00PM'
>
> I want to convert it to :HH:MM
> I tryed it with $heure=(date("H:i",strtotime($row[0]))
> but I get allways 20:55. even when time changes. Whats wrong ?
>
> Does anybody know where I can get a good function which will convert date
> to date and time to time with different formats ?
>[/color]

No, but wouldn't a simple substr(...) + check for AM/PM suffice?

C.
NC
Guest
 
Posts: n/a
#4: Jul 17 '05

re: Time convert problem


Ralf Meuser wrote:[color=blue]
>
> I get form a database time with the format : 'Jan 01 1900 06:00PM'[/color]

What type is the database field? DATETIME?
[color=blue]
> I want to convert it to :HH:MM
> I tryed it with $heure=(date("H:i",strtotime($row[0]))
> but I get allways 20:55. even when time changes. Whats wrong ?[/color]

Since strtotime() returns and unsigned Unix timestamp, it can only
work with dates after the Unix epoch (January 1, 1970).
[color=blue]
> Does anybody know where I can get a good function which will convert
> date to date and time to time with different formats ?[/color]

You can format time on the database server:

SELECT DATE_FORMAT(your_time_field, '%H:%i') as formatted_time
FROM your_table;

Cheers,
NC

Closed Thread