简体   繁体   中英

Convert date time to format “dd.MM.yyyy” from another time zone to +2

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

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.

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM