Create a DateTimeOffset set to Midnight in another TimeZone from the server

I have a server installed in EST and I wonder what I need to do to create a DateTimeOffset installed in Midnight of the current day, but in a different time zone? For example, PST?

+3
source share
1 answer
  • Select the appropriate one TimeZoneInfo.
  • Build a DateTimethat contains local time (i.e. midnight)
  • Call TimeZoneInfo.GetUtcOffsetto find the offset from UTC
  • Build a DateTimeOffsetwith local time and offset

( Noda Time , ZonedDateTime, , , , v1 ... , , , :)

, " " . , , TimeZoneInfo.IsAmbiguousTime TimeZoneInfo.IsInvalidTime.

+6

Source: https://habr.com/ru/post/1784941/


All Articles