Page 1 of 1
Daylight Saving Time - What am I doing wrong here?
Posted: Tue Dec 05, 2006 12:19 pm
by tom_jones
I'm trying to get the current time for Sydney, but it's always 1 hour behind. The DST check evals false even though DST is in effect right now. The code is from Recipe 3.13 of the PHP Cookbook, btw.
Any ideas?
Code: Select all
<?php
// Find the current UTC time
$now = time();
// Sydney is 10 hours ahead
$now += 10 * 3600;
// Is it DST?
$ar = localtime($now,true);
if ($ar['tm_isdst']) { $now += 3600; }
// Use gmdate() or gmstrftime()
echo gmdate ('Y-m-d H:i:s',$now);
?>
Posted: Tue Dec 05, 2006 12:54 pm
by ok
The DST check is regarding your machine (if you are not in Sydney, you probably won't get the same result that you will get in Sydney).
Posted: Tue Dec 05, 2006 2:27 pm
by feyd
If your server is running in UTC, I don't think it will ever have DST enabled. GMT may, but it is in regard to the localized time, not the time you shift it to. You have to set the local timezone to the correct location to get the proper DST for that area (hopefully the code underlying is up to date.)
date_default_timezone_set() may be of interest if you're running PHP 5.1.
Posted: Tue Dec 05, 2006 2:37 pm
by ok
If you use PHP4, try this:
For more information you can look in the comments of the
putenv function.
P.S
Off the topic. How can I link to the PHP manual without writing the full url?
Posted: Tue Dec 05, 2006 2:43 pm
by feyd
ok wrote:Off the topic. How can I link to the PHP manual without writing the full url?
You mean like this?
date()
viewtopic.php?p=252813#252813 
Posted: Tue Dec 05, 2006 2:59 pm
by ok
I read that you tested it only under FF 1.5.0.1, Does it work under FF2?
I don't see buttons (RTM?).

Posted: Tue Dec 05, 2006 3:03 pm
by feyd
It works in Fx 2.
An "RTM-ize" button should appear in the posting pages. On moderator screens it appears before the Syntax list box.
Posted: Tue Dec 05, 2006 3:07 pm
by ok
Posted: Tue Dec 05, 2006 3:19 pm
by feyd
When running subSilver, it is appearing after the Syntax list box, but it still appears for me.
Greasemonkey's running yes? Check the paths that the script is set to execute on: Tools > Greasemonkey > Manage User Scripts.
There should be six urls:
posting.php*
http://devnetwork.net/forums/posting.php*
http://www.devnetwork.net/forums/posting.php*
privmsg.php*
http://devnetwork.net/forums/privmsg.php*
http://www.devnetwork.net/forums/privmsg.php*
With no exclusions.
If you continue to have problems, PM me.
Posted: Tue Dec 05, 2006 3:22 pm
by ok
I didn't notice that I need Greasemonkey. Thanks anyway.