By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,759 Members | 1,727 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,759 IT Pros & Developers. It's quick & easy.

GMT Time Difference

P: n/a
Hi,
Is there any way to get the time difference between Central(US) and GMT in
vb.net.
I'll appreciate your help/suggestion.

Thanks
RC
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
I would assume that all you needed to do was add back the time that Central
time was behind GMT.

Central time is GMT-6 hours.

Just take your current time and add back 6 hours to get to GMT.

"Richard" <Ri*****@nospam.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi,
Is there any way to get the time difference between Central(US) and GMT in
vb.net.
I'll appreciate your help/suggestion.

Thanks
RC

Nov 21 '05 #2

P: n/a
That will work but be sure to check for daylight savings time and adjust
accordingly (GMT - 7)

"Ray Cassick" wrote:
I would assume that all you needed to do was add back the time that Central
time was behind GMT.

Central time is GMT-6 hours.

Just take your current time and add back 6 hours to get to GMT.

"Richard" <Ri*****@nospam.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi,
Is there any way to get the time difference between Central(US) and GMT in
vb.net.
I'll appreciate your help/suggestion.

Thanks
RC


Nov 21 '05 #3

P: n/a
Richard,
DateTime.Now will return the "current" time based on your time zone.

DateTime.ToUniversalTime will return GMT time.

You can subtract the two values to get the difference...

Dim now As DateTime = DateTime.Now
Dim nowGMT As DateTime = now.ToUniversalTime()
Dim diff As TimeSpan = now.Subtract(nowGMT)
Debug.WriteLine(diff, "diff")

Alternatively you could use the various properties of System.TimeZone:

Dim time As DateTime = DateTime.Now

Dim tz As TimeZone = TimeZone.CurrentTimeZone

With tz
Debug.WriteLine(.DaylightName, "daylight name")
Debug.WriteLine(.StandardName, "standard name")
Debug.WriteLine(.GetDaylightChanges(time.Year), "daylight
changes")
Debug.WriteLine(.GetUtcOffset(time), "utc offset")
Debug.WriteLine(.IsDaylightSavingTime(time), "daylight saving
time")
End With

Hope this helps
Jay

"Richard" <Ri*****@nospam.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi,
Is there any way to get the time difference between Central(US) and GMT in
vb.net.
I'll appreciate your help/suggestion.

Thanks
RC

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.