Strtotime ('0000-00-00 00:00') returns a negative value

Php strtotime('0000-00-00 00:00') shows strange behavior. Its returning negative value is approximately -62169984000.

I have a version of Php 5.4.17 on my 64-bit system. It should return the false value that is expected.

But when I checked on another 32-bit system, it returns false.

+4
source share
1 answer

On your system, integers are 64 bits, so there is enough range for counting seconds from the Unix era to 0 AD. Therefore strtotime works as advertised and returns a (very large) negative number. The return value is correct, your expectation is not.

In a 32-bit system, the integer range is sufficient only to cover a period of 68 years, so returning back to about 1970 - 68 = 1902 will return false . Dates between 1902 and 1970 will continue to lead to negative numbers.

+11
source

Source: https://habr.com/ru/post/1492903/


All Articles