3

I want to convert this format:

2012-08-09T07:48:16+02:00

2012-01-17T17:49:05+01:00

2012-01-17T17:49:05-05:00

to "dd.MM.yyyy" in time zone UTC+02:00

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Alex
  • 8,908
  • 28
  • 103
  • 157

2 Answers2

4

Check this way:

    var dt = DateTime.Parse("2012-08-09T07:48:16+02:00");
    var newDt = TimeZoneInfo.ConvertTime(dt, TimeZoneInfo.FindSystemTimeZoneById("FLE Standard Time"));
    Console.WriteLine(newDt.ToString("dd.MM.yyyy"));

By the way, UTC+02:00 it's not name of timezone, real time will depend on country and daylight saving rules.

Uriil
  • 11,948
  • 11
  • 47
  • 68
3

Try this way

TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.Now, "New Zealand Standard Time", "UTC")

More discussions :

How to convert DateTime in Specific timezone?

http://blog.mozilla.org/it/2012/11/16/converting-timezone-specific-times-in-mysql/

Community
  • 1
  • 1
Boopathi Rajan
  • 1,212
  • 15
  • 38