Cannot understand the nature of time () and date () in php

date("Y",1340896077)//1340896077 are the seconds till 2012 from 1970 

gives 2012 what is normal

 And date("Y",1940896077) 

gives 2031, which is also normal

But date("Y",2240896077)

gives 1904, which is absolutely not normal. He should give 2041.

Now I need some explanation on time () and date () in php.

+4
source share
4 answers

What you see is error Y2K38 . 2240896077 too large for a 32-bit integer and is overflowing.

+1
source

PHP uses 32-bit integers.

32-bit integer limited to 2,147,483,647

In the third example, the value is full. Think of it as a KM car counter. Its restriction to a certain value (in our case 2,147,483,647), and as soon as you pass this value back to 0.

This can cause a problem, a 2038 problem (remember the 2000 mistake? A similar concept).

In the “Minutes of the PHP Developers Meeting”, there was a suggestion to add a 64-bit integer , I'm not sure how far it went and what their policy governs time-related functions.

Hope this help :)

+7
source

From the manual:

The valid timestamp range is usually from Fri, 13 Dec 1901 20:45:54 GMT on Tuesday, January 19, 2038 03:14:07 GMT. (These are the dates that correspond to the minimum and maximum values ​​for a 32-bit signed integer). However, before PHP 5.1.0, this range was limited to 01-01-1970 - 19-01-2038 on some systems (for example, Windows).

http://php.net/manual/en/function.date.php

+1
source

The valid timestamp range is usually from Fri, 13 Dec 1901 20:45:54 GMT on Tuesday, January 19, 2038 03:14:07 GMT. (These are the dates that correspond to the minimum and maximum values ​​for a 32-bit signed integer). However, before PHP 5.1.0, this range was limited to 01-01-1970 - 19-01-2038 on some systems (for example, Windows).

C: http://php.net/manual/en/function.date.php

+1
source

All Articles