What is the size of timestamp returned by the strtotime() method in php? I am guessing it 32 bit may be. Is there any way to get a 64-bit timestamp from strtotime('now') in php?
2 Answers
Depends on which PHP architecture you're using. 32-bit PHP = 32-bit time stamps, 64-bit PHP = 64-bit time stamps.
Suggested Solution regardless of architecture
As mentioned by Mark Baker, using the DateTime
object is a safer bet. This avoids the use of architecture detection and provides a plethora of functionality.

- 9,134
- 1
- 30
- 50
-
So, the Year 2038 problem is only because of the architecture limitations? – Rishab Jaiswal Aug 11 '15 at 13:58
-
Correct. Anything past 1/19/2038 exhausts the 32-bit signed integer (2147483647) – Rob W Aug 11 '15 at 13:59
-
I guess I got my solution. Thanks! – Rishab Jaiswal Aug 11 '15 at 14:00
-
2The solution is to switch to using DateTime objects, which are always 64-bit, irrespective of whether you're using 32-bit or 64-bit PHP, instead of unix timestamps – Mark Baker Aug 11 '15 at 14:06
-
I was going to suggest this. Thanks Mark! I'll add to answer. – Rob W Aug 11 '15 at 14:06
My understanding is that it will match the system you are on (and obviously if you are using the PHP 64bit binary); so if you are on a 32bit system it will be 32 and same for 64bit.
i.e.
strtotime("0000-00-00 00:00:00") returns FALSE on a 32 bit system.
strtotime("0000-00-00 00:00:00") returns -62169955200 on a 64 bit system.
Same scenario for dates greater than the year 2038. See http://www.sitepoint.com/is-your-php-application-affected-by-the-y2k38-bug/ for a bit more info.

- 306
- 1
- 7