简体   繁体   中英

size of timestamp returned by strtotime in php

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?

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.

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.

ie

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM