FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Server time?





ChrisCh
Hi all,

As the server (Server 4) is set in GMT time (+0000), I've worked out how to convert this time into my local timezone (Brisbane) to create a variable as follows:
Code:

putenv("TZ=Australia/Brisbane");
$dateTime = date("Y-m-d H:i:s");


Unfortunately, the clock on Server 4 is actually about 10 minutes fast, and as such, the timestamps this code creates are inaccurate. Can anyone suggest how this code could be enhanced to deduct 10 minutes from the clock in my local time zone (that would still work across dates if it was close to midnight)?

My timezone is +1000, however I was only able to discover the "Australia/Brisbane" setting... so if there is a way to set the timezone to +0950 (which would make it almost accurate), I'd love to know! Very Happy

Many thanks in advance!
rickylau
I dont know if you can set a time offset other than "standard time zones", i would suggest another way.

there is one more optional parameter in php date function: the timestamp - you can set the date to output the string of the time other than "now"

and you can offset the current time with one more trick: the strtotime function. Just pass strtotime ("-10 minutes") to the date function and you should get the result you expected
jmraker
If you want to adjust the time and make it readable you can use the strtotime function

Code:
<?php
putenv("TZ=Australia/Brisbane");
$dateTime = date("Y-m-d H:i:s", strtotime('10 minute ago'));
?>


or you can subtract the number of seconds in 10 minutes which I think is 600 seconds

Code:
<?php
putenv("TZ=Australia/Brisbane");
$dateTime = date("Y-m-d H:i:s", time() - 600);
?>
ChrisCh
The subtraction trick worked wonderfully! Very Happy It now appears to be 11 minutes fast, so -660 did the trick.

Thanks to you both - you've saved me a great deal of confusion when trying to work out when private messages were actually sent on my site! Very Happy
Related topics
I Have a question . Is it the server support Chinese?
Need help of a XML Socket Server
Does Frihost's SMTP server require login and password?
Slow Server ?
Game Server For Frihost?_? Lol..
Server Status
Checking Server Status, Ping a Server (lots of purposes)
MySQL Server
Setting up Ftp Server
http://muonline.vn --> New server has copyright of Webzen
Home Server Status Indicator
general server probs!
Ragnarok Online private server...
server doent's work well
php without server
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.