PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
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.
<?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);
?>
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.)