Jump to content

Issue with Date from timestamp


viion

Recommended Posts

I'm having a weird issue going on, I'm wondering if it has to do with my php.ini or server setup, anyway here is the code with the odly outcomes:

 

echo date('Y/m/d H:i:s', 2145000000);
// 2037/12/21 01:20:00

echo date('Y/m/d H:i:s', 2149000000);
// 1901/12/31 01:58:24

echo date('Y/m/d H:i:s', 2150000000);
// 1902/01/11 15:45:04

 

It seems after year 2037 it goes down to 1900+... Why would this happen? I've tried on 2 godaddy servers and local host and all same result :(

Link to comment
Share on other sites

It's called integer overflow: 2147483647+1 = -2147483648.

echo date('Y/m/d H:i:s', 2147483647);
echo date('Y/m/d H:i:s', 2147483648);
echo date('Y/m/d H:i:s', -2147483648);

2038/01/18 19:14:07 (US Pacific coast)
1901/12/13 12:45:52
1901/12/13 12:45:52

 

See also: the Y2K38 bug.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.