On Fri, January 20, 2006 4:24 am, Murray @ PlanetThoughtful wrote: > Wondering if anyone can help me work out why date("H") always adds an > hour? I'm *assuming* it thinks it should be compensating for Daylight > Saving Time (though I'd be just as willing to believe that it's caused > by something else), however we don't observe DST in Queensland, > Australia. > > Making matters a little more complex, while my local machine shouldn't > be compensating for DST (if that's what's happening), my remote > machine > (based in Florida somewhere, I think) should, when applicable. > > So, just to explain a little better. > > Let's say the clock on my computer reads 7:00pm. If I do "echo > date("H");" it will output "20", instead of "19". > > The same thing happens if I take a date value from my mysql database. > > $sql = "SELECT UNIX_TIMESTAMP(datecreated) AS unx_date FROM mytable;" > $rs = mysql_query($sql); > $row = mysql_fetch_object($rs); > echo date("H", $row->unx_date); > > If the above record contained the value '2006-01-10 19:00', the code > would output "20" instead of "19". > > Can anyone help me figure out how to accommodate for this? Ah, the joys of time-zones, and daylight savings. I'd like to kill the guy that thought up daylight savings. Not only does it depend on the machine's location, and where the machine thinks it's located (you could lie to your computer, you know) but also the 'locale' settings and the BIOS UTC setting, and the server's settings in the OS and/or NTP client and... Oh, plus with MySQL, there are settings that can convince MySQL to not pay attention to the OS about its locale/zone settings and to do someting else instead. Tracking down where the fault lies is generally "not fun" But at least now you know where to look :-) I usually throw my hands up in despair and just add/subtract whatever, and then check it again when daylight savings changes over and see if it still works -- Because I have zero control over any of the settings on a shared server anyway. And what's up with these countries with time-zones offset by 15 minutes? What were they thinking? -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php