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
  • 31,815
  • 47
  • 169
  • 296
Alex
  • 7,986
  • 27
  • 93
  • 150

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
  • 10,970
  • 8
  • 45
  • 67
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,174
  • 14
  • 37