Sheep Posted April 18, 2006 Share Posted April 18, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/7711-time/ Share on other sites More sharing options...
zq29 Posted April 18, 2006 Share Posted April 18, 2006 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...[code]<?php$plusonehour = time() + (60 * 60);echo "Now: ".date("H:i:s")."<br/>";echo "+1Hr: ".date("H:i:s",$plusonehour);?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/7711-time/#findComment-28129 Share on other sites More sharing options...
craygo Posted April 18, 2006 Share Posted April 18, 2006 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[code]<?// 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 outecho $formatted_time;?>[/code]Damn!! Apoc beat me to it :)Ray Quote Link to comment https://forums.phpfreaks.com/topic/7711-time/#findComment-28130 Share on other sites More sharing options...
Sheep Posted April 18, 2006 Author Share Posted April 18, 2006 It is my local machine(localhost)... my Windows clock is set correctly, but the time() function gives back one hour earlier... Quote Link to comment https://forums.phpfreaks.com/topic/7711-time/#findComment-28140 Share on other sites More sharing options...
Sheep Posted April 18, 2006 Author Share Posted April 18, 2006 Can someone please respond? Quote Link to comment https://forums.phpfreaks.com/topic/7711-time/#findComment-28155 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.