You are here: Re: [PHP] date("H", $datevalue) always adds an hour? « PHP « IT news, forums, messages
Re: [PHP] date("H", $datevalue) always adds an hour?

Posted by "Richard Lynch" on 01/20/06 23:47

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация