Jump to content


Photo

time()


  • Please log in to reply
4 replies to this topic

#1 Sheep

Sheep
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 18 April 2006 - 12:34 PM

Hello,

When I use my time() function, it returns the time of one hour ago... Can anyone tell how this can be solved? I use the Apache server....

Greetz,
Vincent

#2 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 18 April 2006 - 12:49 PM

Your servers clock is not set correctly, I'm not sure how you'd adjust this with Apache, but you can add an hour onto your time() like this...
<?php
$plusonehour = time() + (60 * 60);
echo "Now: ".date("H:i:s")."<br/>";
echo "+1Hr: ".date("H:i:s",$plusonehour);
?>


#3 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 18 April 2006 - 12:51 PM

Check your system time. The time function returns the current time of the server it is on. I am not farmiliar with apache, but does apache have it's own internal clock???

If you cannot find it you could use this to adjust it

<?
// get current server time
$servtime = time();
// get required offset in seconds
$offset = 60*60;  //60*60 = 3600 seconds or 1 hour
// put them together
$currenttime = $servtime + $offset;
// Format it to your liking
$formatted_time = date("m/d/Y H:i:s", $currenttime);
// Echo it out
echo $formatted_time;
?>

Damn!! Apoc beat me to it :)

Ray

#4 Sheep

Sheep
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 18 April 2006 - 01:09 PM

It is my local machine(localhost)... my Windows clock is set correctly, but the time() function gives back one hour earlier...

#5 Sheep

Sheep
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 18 April 2006 - 01:34 PM

Can someone please respond?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users