derrickc Posted November 19, 2011 Share Posted November 19, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/251418-dreaded-unix-time-stamp-problem-anything-beyond-01-18-2038/ Share on other sites More sharing options...
Pikachu2000 Posted November 19, 2011 Share Posted November 19, 2011 Is this data in a MySQL database to begin with? Quote Link to comment https://forums.phpfreaks.com/topic/251418-dreaded-unix-time-stamp-problem-anything-beyond-01-18-2038/#findComment-1289524 Share on other sites More sharing options...
derrickc Posted November 19, 2011 Author Share Posted November 19, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/251418-dreaded-unix-time-stamp-problem-anything-beyond-01-18-2038/#findComment-1289576 Share on other sites More sharing options...
mikesta707 Posted November 19, 2011 Share Posted November 19, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/251418-dreaded-unix-time-stamp-problem-anything-beyond-01-18-2038/#findComment-1289579 Share on other sites More sharing options...
derrickc Posted November 19, 2011 Author Share Posted November 19, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/251418-dreaded-unix-time-stamp-problem-anything-beyond-01-18-2038/#findComment-1289582 Share on other sites More sharing options...
mikesta707 Posted November 19, 2011 Share Posted November 19, 2011 I've never heard of a 64 bit version of PHP so i'm not sure, sorry. Quote Link to comment https://forums.phpfreaks.com/topic/251418-dreaded-unix-time-stamp-problem-anything-beyond-01-18-2038/#findComment-1289584 Share on other sites More sharing options...
derrickc Posted November 20, 2011 Author Share Posted November 20, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/251418-dreaded-unix-time-stamp-problem-anything-beyond-01-18-2038/#findComment-1289667 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.