Page 1 of 1

Time Stamp Issue

Posted: Thu Jan 28, 2010 8:17 pm
by JakeJ
I'm using a function that returns a future date. In some cases, the date goes beyond 19 Jan 2038 03:14:07 UTC. which is the upper limit for a 32 bit signed integer.

Anyone have a custom function that can some how get around this limit?

Re: Time Stamp Issue

Posted: Thu Jan 28, 2010 9:26 pm
by requinix
Depends what you're doing with it. Post some code.

Re: Time Stamp Issue

Posted: Thu Jan 28, 2010 9:39 pm
by JakeJ
Here's a function I wrote to return a future date based on a number of months from now. My temp fix should be obvious.

Code: Select all

function ffdate($months) {
    If ($months < 335) { #REMOVE THIS IF BEFORE MOVING TO 64 BIT HOSTING
    return date('F, Y ', strtotime("+ {$months} months"));
    }
    Else {
    return "Beyond 2037";
    }
}

Re: Time Stamp Issue

Posted: Fri Jan 29, 2010 6:59 am
by requinix
You can always calculate the date manually.

Code: Select all

month = M
year = Y
monthstoadd = X
 
new month = (M + X - 1) mod 12 + 1
new year = Y + floor(X / 12)
if (new month > 12) {
    new month -= 12
    new year++
}