...

View Full Version : Resolved Which function should I be using to extract the time I want ??



mOrloff
11-07-2010, 12:45 AM
I have a dateTime value like 2010-10-09 18:30:54.
And I want to print it as 6:30:54.

Nothing I've tried is getting me there, and I've worked myself into so many circles that I'm kinda lost.

Please point me in the right direction.

~ Mo

Keleth
11-07-2010, 01:45 AM
http://php.net/manual/en/function.date.php

If you have the datetime already, use strtotime, basically doing this


echo date('g:i:s', strtotime($currentDateTime));

mOrloff
11-07-2010, 04:00 AM
Ooooohh!
strtotime!

Ugh. I didn't even think to go back to square one... Unformat it into a unix timestamp, then reformat the components I need out of it.

Thanks. That helps tremendously.
~ Mo

Keleth
11-07-2010, 04:17 AM
Yup, sometimes that's what it takes... take the specific format, transform to a universal format, then respecify.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum