Php strtotime('0000-00-00 00:00')
showing strange behavior.
Its returning negative value something like -62169984000.
I have Php version 5.4.17 in my 64-bit System. It should return false value which is expected.
But when I checked in other 32-bit system its returning false.
Return Values PHP strtotime() function returns a timestamp value for the given date string. Incase of failure, this function returns the boolean value false.
strtotime expects a "English textual datetime" (according to the manual), which Y-D-M is not. Any time strtotime returns false, it simply doesn't understand your string, which in this application is expected.
The strtotime() function parses an English textual datetime into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 GMT). Note: If the year is specified in a two-digit format, values between 0-69 are mapped to 2000-2069 and values between 70-100 are mapped to 1970-2000.
You can use DateTime::modify to add time, but I would just do time()+10800 . Show activity on this post. $time = new DateTime("+ 3 hour"); $timestamp = $time->format('Y-M-d h:i:s a');
On your system integers are 64 bits, so there is enough range to count seconds from the Unix epoch all the way back 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 only sufficient to cover a ~68 year period, so going back earlier than about 1970 - 68 = 1902 will result in false
being returned. Dates between 1902 and 1970 will still result in negative numbers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With