Page 1 of 1

date() what da... 2038????

Posted: Tue Apr 11, 2006 1:33 pm
by pedrotuga
I am using date() function but it should be some dam ghost or something somewhere (lool, kidding)

what da heck is wrong with this code?

Code: Select all

$query="select date from projectos where ID=$ID";
$result=mysql_query($query);

$array=mysql_fetch_array($result);
echo $array['date'];
echo "<br>"
$strdate=date("j/n/Y",$array['date']);

echo $strdate;

can anybody help me out and tell me why does this code outputs:

Code: Select all

20060322154501
19/1/2038
the timestamp is right.. then the date gets crazzy... help plz

thx in advance.

Posted: Tue Apr 11, 2006 1:43 pm
by John Cartwright
your attempting to use a unix style timestamp, when infact your using a mysql style timestamp

the date() function expects a unix timestamp

unix - seconds since epoch
mysql - yyyymmddhhmmss

Posted: Tue Apr 11, 2006 1:49 pm
by pedrotuga
mmmm....

ok then, how do i go around this problem then?

whats the tipical solution?

Posted: Tue Apr 11, 2006 2:03 pm
by timvw
You can use the MySQL DATE_FORMAT function and get the right format there...
(or UNIX_TIMESTAMP and format with php)

Posted: Wed Apr 12, 2006 6:17 am
by pedrotuga
thanks
solved