views:

70

answers:

2

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?

+5  A: 

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.

htw
I've noted that in my diary.
pavium
Thank you, I was little bit confused. Now I am cleared
RSK
Then accept the anwser so he can get rep.
e-satis
A: 

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!?

powtac
I don't think this changes anything, since the underlying operating system is what is storing the time. PHP doesn't have anything to do with it, really.
htw
Ok, check the pear solution.
powtac