You are here: Re: Does UTC take DST into account? « PHP Programming Language « IT news, forums, messages
Re: Does UTC take DST into account?

Posted by ljb on 02/11/07 03:15

cutenfuzzy@gmail.com wrote:
> Hi everyone. I know this question sounds stupid, but it's been
> plaguing me, and as I can't seem to find the answer, and can't afford
> to wait until the end of March for DST to kick into effect, I thought
> I should ask here.

If you are in US or Canada, and your -0800 offset implies that, that would
be 2nd Sunday in March, not end of March. Just so you know. (And spelling
'utilise' implies Canada, I guess. Someplace like Vancouver?)

> On my server, when I do:
>
> echo date("0", mktime());
>
> I get -0500. This suggests to me that the server is 5 hours behind GMT/
> UTC time.

Assuming the server's timezone is set correctly, it is perhaps in east
coast US, eastern Canada, or even western South America. (FYI that's "O"
letter Oh, not "0" zero.) You could print out date('T') to see the timezone
name, or even better with PHP>=5.1 date('e') to see the descriptive name.

> When I do:
>
> echo gmdate("0", mktime());
>
> I get +0000 , which is correct. However, the time I get is 1 hour 1
> minute and 52 seconds ahead of what the actual GMT time is.

That's odd. How did you get that time?
If it was just 1 min 52 seconds, I would say the server time is
unsynchronized (assuming your time is accurate). But I don't understand
the hour. If that's really the server's GMT time, that would be bad.

> Does this mean that the locale is wrong, or would I simply subtract
> and hour from the supposed GMT and get on with it?

Locale has nothing to do with it. The server's timezone setting is
used to produce local time. UTC (GMT) is UTC no matter what.
I would probably ask the server/hosting company what's up there.

> The question that's plaguing me, is will the time leap forward on the
> last Sunday of March, and would it be affected by whether or not the
> country that the server is in conforms to DST?

UTC doesn't change. Local time is subject to the timezone setting; that
would default to the server's timezone or your scripts can set it.
If the selected timezone includes a DST change, local time changes.
In most of US and Canada, local time jumps 1 hour on March 11, 2007.

> I need to utilise a constant time (UTC), so I can tweak my script, and
> never have to worry about different timezones and DST, but I am not
> sure if I am doing it the right way.
>
> I would appreciate it if someone could point out where I might be
> going wrong (if anywhere), or whether it sounds like the server
> locales are set incorrectly from what I have tried to explain.

What I recommend you need to be sure this all works:
1. Your server O/S needs up-to-date timezone data (if Linux or Unix),
or Microsoft patches (if Windows). Less important for PHP>=5.1
which has its own timezone database, I think.
2. Your server's time should be synchronized with NTP. Should go without
saying, but sometimes ignored, sadly.
3. Use an up-to-date PHP version like 5.2.0.
4. Your timezone should be set to match your (or your users) timezone - not
necessarily the server's timezone. If you control the server's php.ini,
set it there with "date.timezone". If not, then set it in your scripts with
date_default_timezone_set(). (These are for PHP 5.1 and up, I think.)

 

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

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