Page 1 of 1

I need help with my timestamp...

Posted: Tue Dec 05, 2006 10:30 am
by midohioit
While pulling a timestamp off of a mysql database I am having a small issue with the results.

the data on the database looks like this, the column is called start_time:
16:30:00

I want to convert this to make it look cleaner. I am using the following code:

$st = $array[start_time];
......

$startime = date("g:i a", mktime($st));

The following is the result that I get:
4:13 pm

(:13 is what the current time is on the server, not :30 which is part of the data...)
Can someone please tell me why I can not get the minutes? :D

Timestamp

Posted: Tue Dec 05, 2006 10:32 am
by timclaason
I always use

Code: Select all

date("H:i:s");

Posted: Tue Dec 05, 2006 10:43 am
by Corvin

Code: Select all

<?php
$startime = date("g:i a", strtotime($st));
?>

Posted: Tue Dec 05, 2006 10:45 am
by feyd
mktime() will not parse strings in the manner you wish. strtotime() will. However you could also ask MySQL to return the result in unix timestamp form.

thanks!

Posted: Tue Dec 05, 2006 2:53 pm
by midohioit
$startime = date("g:i a", strtotime($st));

was my fix, thank you all for your help!