473,395 Members | 1,941 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Daylight time wrong UTC time

I created a UTC clock using this:
UTCTime = MyTime.ToUniversalTime()
Now that we've turned the clocks ahead 1 hour for daylight savings time, the
clock is reporting the wrong UTC time. It is reporting UTC + 1 hour.
Is this a bug or is there a way I can querey for daylight time and make the
adjustment in my application?

Thanks.
Nov 21 '05 #1
7 4062
This came up a few weeks ago in this newsgroup. Basically, MS Explorer shows
the correct time whereas the applications show MS Explorer time + 1 hour.
So, I guess it is an error

Crouchie1998
BA (HONS) MCP MCSE.
Nov 21 '05 #2
I think it is a bit imprudent to call it an error.

I, for example have never seen the bahaviour that has been described
regardless if the macine is in daylight saving time or not and also
regardless of whether or not daylight saving time has just cut in or out as
the case may be.

I think the appropriate course of action is for the original poster to
identify the specific condition that is causing the behaviour in the
configuration of the machine in question.
"Crouchie1998" <cr**********@spamcop.net> wrote in message
news:Oj**************@tk2msftngp13.phx.gbl...
This came up a few weeks ago in this newsgroup. Basically, MS Explorer
shows
the correct time whereas the applications show MS Explorer time + 1 hour.
So, I guess it is an error

Crouchie1998
BA (HONS) MCP MCSE.

Nov 21 '05 #3
Brett,

This gives me the correct UTC time (In the EU is summertime, as it is named
here started, with Easter).

MessageBox.Show(Now.ToUniversalTime.ToString)
I hope this helps,

Cor
Nov 21 '05 #4
Here's whole little thing for clarification...

Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As
System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
MyTime = TimeOfDay
UTCTime = MyTime.ToUniversalTime()
TextBox1.Text() = UTCTime

End Sub

-Brett

"Stephany Young" wrote:
I think it is a bit imprudent to call it an error.

I, for example have never seen the bahaviour that has been described
regardless if the macine is in daylight saving time or not and also
regardless of whether or not daylight saving time has just cut in or out as
the case may be.

I think the appropriate course of action is for the original poster to
identify the specific condition that is causing the behaviour in the
configuration of the machine in question.
"Crouchie1998" <cr**********@spamcop.net> wrote in message
news:Oj**************@tk2msftngp13.phx.gbl...
This came up a few weeks ago in this newsgroup. Basically, MS Explorer
shows
the correct time whereas the applications show MS Explorer time + 1 hour.
So, I guess it is an error

Crouchie1998
BA (HONS) MCP MCSE.


Nov 21 '05 #5
I changed my querey of the current time from:
TimeOfDay() to Now()
This fixes the problem

Brett

"Brett Edman" wrote:
I created a UTC clock using this:
UTCTime = MyTime.ToUniversalTime()
Now that we've turned the clocks ahead 1 hour for daylight savings time, the
clock is reporting the wrong UTC time. It is reporting UTC + 1 hour.
Is this a bug or is there a way I can querey for daylight time and make the
adjustment in my application?

Thanks.

Nov 21 '05 #6
Well, that puts things in perspective.

Throw a couple of telltales in and you will see what is happening.

MyTime = TimeOfDay
Console.Writeline(MyTime.ToString())
UTCTime = MyTime.ToUniversalTime()
Console.Writeline(UTCTime.ToString())
TextBox1.Text() = UTCTime

Note what date part of the results shows.

From the documentation on the TimeOfDay property:

<quote>
Returns or sets a Date value containing the current time of day according to
your system.
</quote>

<furtherquote>
The Date data type includes date components. When returning the system time,
TimeOfDay sets these all to 1, so the returned value represents the first
day of the year 1.
</furtherquote>

When I execute you EXACT code I get 12:00:00 AM and the telltale shows
1/01/0001 12:00:00 AM. This timezone during daylight saving is UTC+13 hours
and the current time is about 10:30 AM. Subtracting 13 hours from 1/01/0001
10:30:00 AM would give 31/12/0000 9:30:00 PM but that is prior to the lowest
value allowed for a date and so it uses the lowest allowed as the result.

When I execute the following:

Dim MyTime As Date = CDate("01/01/0001 18:30:00")
Console.WriteLine(MyTime.ToString())
Dim UTCTime As DateTime = MyTime.ToUniversalTime()
Console.WriteLine(UTCTime.ToString())

I get:

1/01/0001 6:30:00 PM
1/01/0001 5:30:00 AM

Which is what I expect during daylight saving (UTC+13 hours). 1 January
falls within the daylight saving period down this end of the world.

When I modify the code to:

Dim MyTime As DateTime = CDate("30/06/0001 18:30:00")

I get:

30/06/0001 6:30:00 PM
30/06/0001 6:30:00 AM

Which, again, is what I expect during standard time (UTC+11 hours).

When I execute the first block of code (above) I notice a significant delay
betwen the first and second telltales being displayed. The delay is of about
the length that I observe when an exception is about to be thrown. I suspect
that some extra maths is going on here to ensure that the result is not
prior to the lowest value allowed for a date.

Given these findings, in my opinion, if the result of a date calculation
gives a result prior to the lowest value allowed for a date than a suitable
exception should be thrown rather than returning an erroneous value.

HOWEVER!

If you use:

Dim MyTime As DateTime = DateTime.Now
Console.Writeline(MyTime.ToString())
Dim UTCTime As DateTime = MyTime.ToUniversalTime()
Console.Writeline(UTCTime.ToString())
TextBox1.Text() = UTCTime.ToLongTineString()

You will always get the correct result in relation to your current timezone
(regardless of the daylight saving status) and your current culture.

I must say that it never would have occurred to me to try and convert a time
part to UTC because UTC is as much to do with the date part as it is the
time part. Maybe it's because, down this this end of the world, we spend at
least half our time having a different date than UTC does and perhaps that
makes us more aware of the need to make sure we use the correct techniques
when converting to and from UTC. In Western Europe, for example the date is
only different for, at most, 2 hours per day and that is when most sane
people are asleep and maybe the difference is not noticed anywhere as much.

I hope I have managed to make this a clear as mud and I'll see you on our
next 'date' :)
"Brett Edman" <Br********@discussions.microsoft.com> wrote in message
news:00**********************************@microsof t.com...
Here's whole little thing for clarification...

Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As
System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
MyTime = TimeOfDay
UTCTime = MyTime.ToUniversalTime()
TextBox1.Text() = UTCTime

End Sub

-Brett

"Stephany Young" wrote:
I think it is a bit imprudent to call it an error.

I, for example have never seen the bahaviour that has been described
regardless if the macine is in daylight saving time or not and also
regardless of whether or not daylight saving time has just cut in or out
as
the case may be.

I think the appropriate course of action is for the original poster to
identify the specific condition that is causing the behaviour in the
configuration of the machine in question.
"Crouchie1998" <cr**********@spamcop.net> wrote in message
news:Oj**************@tk2msftngp13.phx.gbl...
> This came up a few weeks ago in this newsgroup. Basically, MS Explorer
> shows
> the correct time whereas the applications show MS Explorer time + 1
> hour.
> So, I guess it is an error
>
> Crouchie1998
> BA (HONS) MCP MCSE.
>
>


Nov 21 '05 #7
On Tue, 19 Apr 2005 10:04:05 -0700, "Brett Edman"
<Br********@discussions.microsoft.com> wrote:

I may be wrong, but I thought that UTC/GMT doesn't change with the
seasons, so here we are on BST at the moment or GMT +1

Doug Taylor
I changed my querey of the current time from:
TimeOfDay() to Now()
This fixes the problem

Brett

"Brett Edman" wrote:
I created a UTC clock using this:
UTCTime = MyTime.ToUniversalTime()
Now that we've turned the clocks ahead 1 hour for daylight savings time, the
clock is reporting the wrong UTC time. It is reporting UTC + 1 hour.
Is this a bug or is there a way I can querey for daylight time and make the
adjustment in my application?

Thanks.


Nov 21 '05 #8

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

Similar topics

0
by: Jonatan Fernstad | last post by:
I am using the JavaMail API to send email. It seems the Message.setSentDate(new Date()) sets wrong time zone. I am at GMT+1, and this is also what the new Date() is showing. But when the...
9
by: Admin | last post by:
I am creating a chat application like Messenger for the web (using the browser) and I'm wondering if there is a way to receive new messages from time to time from the server other than refreshing...
3
by: Russell Warren | last post by:
Does anyone know how long it takes for time.clock() to roll over under win32? I'm aware that it uses QueryPerformanceCounter under win32... when I've used this in the past (other languages) it...
5
by: RICHARD BROMBERG | last post by:
I am writing an ASP program that includes a Form. When the Form is submitted I use the Date() and Time() functions to put the date and time into the Body part of the e-mail. The time reported is...
0
by: amy | last post by:
it seems a bug of CDateTimeCtrl: if I try to set "2004/4/4 2:00" (which is daylight saving start time) to it, it always shows "2004/4/4 1:00". But when I set "2003/10/26 2:00" to it, it...
0
by: nishi.hirve | last post by:
Hello, I am writing one simple C# .NET application in which I have to use the values retrived from the database. But when I try to retrive value of attribute of type Time without time zone it...
9
by: Ron Adam | last post by:
I'm having some cross platform issues with timing loops. It seems time.time is better for some computers/platforms and time.clock others, but it's not always clear which, so I came up with the...
0
by: eneyardi | last post by:
I want to have my program time in, time out system. When someone login, automatically it will record the time it was in, and when logging out, it will record the time out. I want to have a database...
3
by: beary | last post by:
Hi, My php website is showing the wrong time. I don't think it's a timezone thing. The website is running purely on my local machine under localhost. It's around 10 hours slow, which means when I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.