GMT Time Difference

  • Thread starter Thread starter Richard
  • Start date Start date
R

Richard

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
 
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.
 
That will work but be sure to check for daylight savings time and adjust
accordingly (GMT - 7)
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top