ballhogjoni Posted January 29, 2009 Share Posted January 29, 2009 I can't figure this one out. My is : strtotime(2009-01-29 12:44:12) - time(); and I keep getting random numbers. I get like 539, 408, 670,324, etc... I diagnosed it to the time() it keeps returns random seconds. Any ideas why this is happening? Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted January 29, 2009 Share Posted January 29, 2009 try looking at this http://us.php.net/manual/en/function.strtotime.php Quote Link to comment Share on other sites More sharing options...
printf Posted January 29, 2009 Share Posted January 29, 2009 time(); // returns the number of seconds since Jan 1, 1970 (Uinx Epoch), it always changes! Quote Link to comment Share on other sites More sharing options...
ballhogjoni Posted January 29, 2009 Author Share Posted January 29, 2009 time(); // returns the number of seconds since Jan 1, 1970 (Uinx Epoch), it always changes! LOL good point. I guess I should have explained myself a little better. I am taking the value of this (strtotime(2009-01-29 12:44:12) - time() equation and creating a countdown from the value. this will give the seconds I need to create that countdown. The problem is that if I refresh the page it will give me a random number of seconds (not what i'm expecting). Lets say the equation gave me 600 seconds the first time I go to the page and then I refresh the page one second later and I get 300 seconds as a value from the equation. You see the problem is that the equation is giving a random number of seconds. I was able to pinpoint the issue to the time(). Quote Link to comment Share on other sites More sharing options...
redarrow Posted January 29, 2009 Share Posted January 29, 2009 little example for you. <?php //1 month $Time=strtotime("2009-01-29 12:44:12 -1 MONTH"); echo" ".date("M/d/y,h:i:s",$Time)." <br>"; // 1 week. $Time=strtotime("2009-01-29 12:44:12 -1 WEEK"); echo" ".date("M/d/y,h:i:s",$Time)."<br> "; // 1 year. $Time=strtotime("2009-01-29 12:44:12 -1 YEAR"); echo" ".date("M/d/y,h:i:s",$Time)."<br> "; // 1 week 1 day. $Time=strtotime("2009-01-29 12:44:12 -1 WEEK 1 DAY"); echo" ".date("M/d/y,h:i:s",$Time)."<br> "; // 1 week 1 day= 3 hours 2 secounds $Time=strtotime("2009-01-29 12:44:12 -2 WEEK 1 DAY 3 HOURS 2 SECONDS"); echo" ".date("M/d/y,h:i:s",$Time)."<br> "; ?> what is it your trying to do please, so we no. Quote Link to comment Share on other sites More sharing options...
ballhogjoni Posted January 29, 2009 Author Share Posted January 29, 2009 Why does time() give you a random number (not incremental) when you refresh the page. I thought it was supposed to give the number of seconds since 1970. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted January 29, 2009 Share Posted January 29, 2009 It should be displaying an increasing number approximately in the ball park of 123326xxxx, depending on what your local server's time is. Either your php installation is having a problem, or your server's time is being dynamically changed or your code that is using the result of the time() value has a bug in it. Quote Link to comment Share on other sites More sharing options...
ballhogjoni Posted January 29, 2009 Author Share Posted January 29, 2009 What if I jsut use date("U") Quote Link to comment Share on other sites More sharing options...
DarkWater Posted January 29, 2009 Share Posted January 29, 2009 Umm, I hope you have quotation marks around the date/time in this: strtotime(2009-01-29 12:44:12) - time() You do, right? Quote Link to comment Share on other sites More sharing options...
ballhogjoni Posted January 29, 2009 Author Share Posted January 29, 2009 Umm, I hope you have quotation marks around the date/time in this: strtotime(2009-01-29 12:44:12) - time() You do, right? no, its actually a variable. just put a date in the strtotime for example Quote Link to comment 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.