473,506 Members | 16,201 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Does UTC take DST into account?

Daz
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.

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.

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.

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

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?

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.

Many thanks in advance.

Daz.

Feb 10 '07 #1
1 5327
Daz
On Feb 11, 3:15 am, ljb <lba...@pobox.com.delete.thiswrote:
cutenfu...@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?)
It's -0500, not -0800 :)
>
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.
I did echo gmdate("M d Y H:i:s", mktime());

And the time is an hour ahead of my PC clock, which is in the UK and
synchronised. Just in case, I checked out http://
wwp.greenwichmeantime.com/ which displays the correct GMT, which
displays the same time as my PC clock (to the second).
>
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.
I did exactly that. I asked them to look into it, they said they
would, and never got back to me. Heh. They are usually pretty good, so
I will give them a kick in the butt.
>
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.
Oh, I see. Excellent. It makes complete sense now.
>
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.
Ironically enough, I switched over to PHP 5 yeasterday. The settings
take about 15 minutes to propagate, and I never went back and checked
it then. I just checked it now, and my Control Panel says I am running
PHP 5.1, but running:
php -version
at the command line, reveals I am still running php 4.4.2. I'll get
them to look into that.

I just logged in, and when I do 'date' at the CL, I get: Sun Feb 11
08:41:14 EST 2007

For my PC (Linux), I get: Sun Feb 11 12:38:17 UTC 2007

That means the server time is actually -0400, not -0500 like PHP says.
This is so confusing...

Also, both dates were taken within 0.5 seconds of oneanother.
2. Your server's time should be synchronized with NTP. Should go without
saying, but sometimes ignored, sadly.
Yeah, I think I am going to speak to my host about that.
3. Use an up-to-date PHP version like 5.2.0.
Hmmm. I think we only have 4, 5 or 5.1 available for grabs at the
moment. Can you confirm it's safe, and backwards compatible. I heard
there were some problems in the past, but I don't know if they were
rumours, or if the problems have been fixed or not. Either way, I
didn't want to take the chance with my Web site.
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.)
You are right. Thank you very much for your input. I am pretty certain
now that there is a problem with the server. :)

Daz.
Feb 11 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
6505
by: Ron | last post by:
Hi all I'm deciding whether to use the PK also as an account number, invoice number, transaction number, etc that the user will see for the respective files. I understand that sometimes a...
6
467
by: Bob | last post by:
Having trouble getting started. I created an instance of MSDE called VSDOTNET on a computer with the name of sysdev. Using MS SQL Web Adminstrator I created a database called temp with a...
3
5668
by: Doctor Who | last post by:
I am running a Windows 2003 Server w/Framework 1.1 loaded. We have built a ..NET 2003 app and it requires that ASPNET be assigned permissions to several folders and servcies. The ASPNET account...
7
2039
by: sammy | last post by:
ok... so i restarted my server and i get a "Server Application Unavailable The web application you are attempting to access on this web server is currently unavailable. Please hit the "Refresh"...
12
1314
by: RKay | last post by:
I have a Win2k server running SQL Server 2000. On that box I built a working web service that pulls data from the database. One of the services available simply accepts an ado.net connection string...
2
5400
by: rrossney | last post by:
Please look at the "what I've already done" section of this message before responding to it: I believe that I've done everything that the people who experience this error are typically told to do....
7
1323
by: Damien | last post by:
Hi Guys, <Posted yesterday to microsoft.public.dotnet.framework.aspnet.security, but no responses garnered. For mpsc readers, this is a fairly common error encountered when connecting from...
1
1972
by: CrimeMaster | last post by:
I have write some simple code,this code does not shows network mapped drives when we run it under system account, otherwise under user account it shows them correctly. Any body tell me why did...
3
2350
by: chaitanya02 | last post by:
I have problem joining four tables using Inner Join in ACCESS DB, I want to join 4 tables: 1, 2, 3 , 4 ....and query data in all these to see, i get a right url associated. sql1-account id,...
8
1312
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi for some reason in the code below even when the file exits the code below never executes int a = 1; does the path have to contain the entire physical path including the drive? string...
0
7220
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7308
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7371
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
5037
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3188
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3178
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
410
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.