How to know date at a timezone if date at UTC in known and time at that timezone is known?

For example:

  • I know the date in UTC is 2020-05-15
  • I know the Time in Pacific/Auckland (+12) is 8:00

How do I calculate the date in Pacific/Auckland (+12) with this known data?

Jon Skeet
people
quotationmark

I'd take the simple approach of "try the obvious date/time combination, and see whether it works":

  • Try a DateTime using the "UTC date" and local time, in the given time zone. In this case, you'd end up with 2020-05-15T08:00:00 in Pacific/Auckland
  • Convert that DateTime to UTC, in this case ending up with 2020-05-14T20:00:00Z
  • Check the resulting date:
    • Is it too early? Advance our candidate by one day.
    • Is it too late? Move our candidate back by one day.
    • Is it right? Great - our candidate was already correct.

people

See more on this question at Stackoverflow