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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
pedrotuga
Forum Contributor
Posts: 249
Joined: Tue Dec 13, 2005 11:08 pm

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

Post 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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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
User avatar
pedrotuga
Forum Contributor
Posts: 249
Joined: Tue Dec 13, 2005 11:08 pm

Post by pedrotuga »

mmmm....

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

whats the tipical solution?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

You can use the MySQL DATE_FORMAT function and get the right format there...
(or UNIX_TIMESTAMP and format with php)
User avatar
pedrotuga
Forum Contributor
Posts: 249
Joined: Tue Dec 13, 2005 11:08 pm

Post by pedrotuga »

thanks
solved
Post Reply