Creating a DateTime in a specific Time Zone in c#

I’m trying to create a unit test to test the case for when the timezone changes on a machine because it has been incorrectly set and then corrected.

In the test I need to be able to create DateTime objects in a none local time zone to ensure that people running the test can do so successfully irrespective of where they are located.

From what I can see from the DateTime constructor I can set the TimeZone to be either the local timezone, the UTC timezone or not specified.

How do I create a DateTime with a specific timezone like PST?

9 Answers
9

Leave a Comment