-
-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
As a tech, I'd like to add 2 new helpers to convert a certain Datetime to a specific timezone
Example:
Convert straight from UTC:
DateTime utcTime = DateTime.UtcNow; // Or your existing UTC DateTime
DateTime targetTime = TimeZoneInfo.ConvertTimeFromUtc(utcTime, targetTimeZone);
return targetTime;
If your initial DateTime is in a different timezone (e.g., local time):
DateTime sourceTime = DateTime.Now; // Or your existing local DateTime
TimeZoneInfo sourceTimeZone = TimeZoneInfo.Local; // Or the appropriate TimeZoneInfo for your source
DateTime targetTime = TimeZoneInfo.ConvertTime(sourceTime, sourceTimeZone, targetTimeZone);
return targetTime;
As result this should generate a new Datetime with the calculated timezone.
Metadata
Metadata
Assignees
Labels
No labels