Reputation: 7113
I've dates in different time zones.
How to convert them to UTC giving the respective time zone.
Something like this:
Dim Dated as DateTime = TempDate.ConvertToUniversalTime(TimeZone)
Upvotes: 1
Views: 8317
Reputation: 7113
Here's how to do it
Dim TimeZone As TimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("W. Europe Standard Time")
Dim Dated As DateTime = TimeZoneInfo.ConvertTimeToUtc(TempDate, TimeZone)
For the TimeZones IDs check:
TimeZone.GetSystemTimeZones
Upvotes: 3
Reputation: 7553
The DateTime object in .net provides the DateTime.ToUniversalTime method. Since you are using the VB Date type the DateTime.FromOADate and DateTime.ToOAdate will provide conversion between the Date and DateTime types (see Interop Considerations under Programming Tips here).
UPDATE: You might also want to check out Converting Times Between Time Zones.
Upvotes: 4