By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,361 Members | 1,683 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,361 IT Pros & Developers. It's quick & easy.

Time convert problem

P: n/a
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

Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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" <rm*****@free.fr> wrote in message
news:42***********************@news.free.fr...
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

Jul 17 '05 #2

P: n/a
Ralf Meuser wrote:
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 ?


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

C.
Jul 17 '05 #3

P: n/a
NC
Ralf Meuser wrote:

I get form a database time with the format : 'Jan 01 1900 06:00PM'
What type is the database field? DATETIME?
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 ?
Since strtotime() returns and unsigned Unix timestamp, it can only
work with dates after the Unix epoch (January 1, 1970).
Does anybody know where I can get a good function which will convert
date to date and time to time with different formats ?


You can format time on the database server:

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

Cheers,
NC

Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.