*** using mySql timestamp date with php date() :(
Posted: Mon Jan 19, 2004 7:30 pm
IM a newbie and I am really stumped here. In my mySql DB i have a dateTime field of type TIMESTAMP(14). When I retrieve this dateTime value (i.e. 20040125103000 for Sunday Jan 25 2004 10:30) and i use php's date() function I get incorrect results. Here is an example of my problem ...
$timeStamp1 = 20040125103000;
$day = date("l, M d", (int)$timeStamp1); //i.e. Sunday, Jan 25
$time = date("g:i a", (int)$timeStamp1); //i.e. 10:30 am
echo "<br>Day = $day and time = $time";
My output should say - Day = Sunday, Jan 25 and Time = 10:30 am
But my output is - Day = Thursday, Nov 28 and time = 1:17 am
I searched the forums and read the manuals and couldnt find my problem.
Any help would be very much appreciated.
TIA
J
$timeStamp1 = 20040125103000;
$day = date("l, M d", (int)$timeStamp1); //i.e. Sunday, Jan 25
$time = date("g:i a", (int)$timeStamp1); //i.e. 10:30 am
echo "<br>Day = $day and time = $time";
My output should say - Day = Sunday, Jan 25 and Time = 10:30 am
But my output is - Day = Thursday, Nov 28 and time = 1:17 am
I searched the forums and read the manuals and couldnt find my problem.
Any help would be very much appreciated.
TIA
J