Jump to content

Dreaded Unix time stamp problem - anything beyond 01-18-2038


derrickc

Recommended Posts

for ($z=1;$z<=30*365; $z++)
{
$bal[date('Y-m-d', strtotime("+ ". $z ." days"))] = $balance;//the balance of loan here.;
}

 

As you can see Im working on loading the daily balance of a 30 year loan in an array.

 

The code goes to hell in the year 2038.  I have scoured the internet for help.  I have gone to the wikipedia link and have looked at other posts but there isn't quite something that can help me.  How can I load dates beyond 01-18-2038 into my array?

 

I have heard of ways to do it with MySQL and the DATETIME() function, but that doesn't seem to make sense for what I am trying to accomplish.

 

Please point me in the right direction.

 

Thanks.

Link to comment
Share on other sites

Im pulling the loan balance from a mysql db, but doing all of the calculations and then storing the data into an array.

 

Oh by the way, I have looked to install WAMP because there is supposedly a 64 bit version of php and that is supposed to solve the problem but it didn't work.

Link to comment
Share on other sites

The reason that a 64 bit version of PHP will work is because 64 bit refers to the length of an int in the system. with 32 bits, the maximum integer value that any single variable can hold is 2^32 -1 (i think its -1, cant quite remember exactly), and this of course, coincides with the date of 1-18-2038 (since that date is, apparently, exactly 2^32 -1 seconds after the Unix epoch).

 

Beyond getting the 64 bit version, there isn't much you can do that I can think of.

Why exactly do you need a date at that point in the future? Is there an alternative you can do? What exactly are you calculating, and how are you calculating it?

Link to comment
Share on other sites

I am using easyphp 5.38 on my windows 7 machine to do all my testing and development.  I believe it comes with the 32 bit version,  where is a good source to get a copy of a 64 bit version of php?  From what I understand php.net doesn't have a 64bit version.

 

Thanks

Link to comment
Share on other sites

So I have figured out a way to work around the issue.

JD and Gregorian calendar forumlas!

 

Here is a basic loop that will spit out what im trying to accomplish:

 

$jd = gregoriantojd(11,19,2011);
$jdend = gregoriantojd(11,19,2041);
for($w=$jd;$w<=$jdend;$w++)
{
$jd = $jd+1;
$gregorian = jdtogregorian($jd);
echo $gregorian . "<br />";	
}

 

Thanks.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.