-
Now, Singapore uses Singapore Time (utc + 8), but due to historical reasons, Singapore has revised the zone time several times. Ref : link. var utc = DateTime.SpecifyKind(new DateTime(1942, 5, 1), DateTimeKind.Utc) ;
var timeZone = TimeZoneInfo.FindSystemTimeZoneById("Singapore Standard Time");
var sgDate = TimeZoneInfo.ConvertTimeFromUtc(utc, timeZone); // expected 1942-5-1 +09:00 , but output 1942-5-1 +08:00 How to handle this scenario in .NET? |
Beta Was this translation helpful? Give feedback.
Answered by
elgonzo
Feb 7, 2025
Replies: 1 comment 6 replies
-
See #53519 (comment) It depends on the time zone data source in use. |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you need something now that works on Windows (and other platforms targetted by .NET), try using the NodaTime package which supports IANA TZDB (time zone database).
Your code example adopted for NodaTime could for example look like this:
with the output of this example being something like
1942-05-01T09:00:00 Asia/Singapore (+09)
.