TimeZoneInfo.FindSystemTimeZoneById
takes in an ID found within the registry of Windows (specifically, HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Time Zone), thus it must be one that exists on the machine. Los Angeles is in the "Pacific Standard Time" zone.
Thus, to calculate the current Los Angeles time, you would need to first get the TimeZoneInfo
for the "Pacific Standard Time" zone, and then you can get the current UTC time and Add
the TimeZoneInfo
's BaseUtcOffset
to it to calculate the time in Los Angeles.
TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time");
DateTime laTime = DateTime.UtcNow.Add(timeZoneInfo.BaseUtcOffset);