开发者

How long the time function works in php

Is php date() and time() function works between the years 1901-2038. What function开发者_运维问答 will I use for my long based projects. or I am wrong?


The timestamp only wraps around after January 19, 2038 on 32-bit systems. On 64-bit systems, this is not an issue, since most 64-bit operating systems use signed 64-bit integers for storing the timestamp. (With signed 64-bit integers, the timestamp wraps around on December 4, 292,277,026,596 AD.)

By 2038, I'd bet that most computer systems will be running on 64-bit architecture (at least), so it probably won't be a problem in the long run. Besides, there's nothing you yourself can do about it—it's an issue with the underlying operating system and processor architecture, not the code you write.


You can always use the PEAR::Date class, it can be used for dates before 1970 and after 2038.

Example:

require_once 'Date.php';

$longAgo = new Date('1813-02-23T05:34:23');

echo $longAgo->getTime();
echo $longAgo->getDate();

Maybe also the The DateTime class can do it!?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜