Jump to content

Crazy issue with time()


ballhogjoni

Recommended Posts

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().

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.