2

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?

Rishab Jaiswal
  • 349
  • 3
  • 19

2 Answers2

5

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.

Rob W
  • 9,134
  • 1
  • 30
  • 50
2

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.

Neddage
  • 306
  • 1
  • 7