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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

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.