I had the interesting request that it was important to a system (SalesForce) to set the right time including the timezone.
So I created a .Net function with a string as input and a string as output. This function is call from a map. Here are the function:
DateTime myDateTime = Convert.ToDateTime(input);
TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById(“W. Europe
Standard Time”);
Standard Time”);
TimeSpan offset =
tzi.GetUtcOffset(myDateTime);
tzi.GetUtcOffset(myDateTime);
DateTimeOffset d = new DateTimeOffset(myDateTime, offset);
string
output = d.ToString(“o”);
output = d.ToString(“o”);
The Id of the zone can be found by running through all the names by running this code:
ReadOnlyCollection<TimeZoneInfo> zones = TimeZoneInfo.GetSystemTimeZones(); Console.WriteLine("The local system has the following {0} time zones", zones.Count); foreach (TimeZoneInfo zone in zones) Console.WriteLine(zone.Id);
The result is in a format that this, which also takes care of DST (Daylight saving time):2012-07-02T02:12:00.0000000+02:00 (input --> 02-07-2012 02:12) 2012-02-28T14:00:00.0000000+01:00 (input --> 28-02-2012 14:00)
Random posts:
- Nothing like a misty autumn morning with your Nikon D800 and a couple of lenses
- BizTalk ESB Toolkit 2.1 installation guide
- FCKs transfer vindue 2011/12
- Welcome to app construction
- Dynamic reference in Excel
Help me, help you. You know how 😉 (click, click, click…)