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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.