Skip to content

Instantly share code, notes, and snippets.

@imraja
Created April 4, 2024 16:00
Show Gist options
  • Select an option

  • Save imraja/ba1f32c80dbe421068fb4487dc7a76d1 to your computer and use it in GitHub Desktop.

Select an option

Save imraja/ba1f32c80dbe421068fb4487dc7a76d1 to your computer and use it in GitHub Desktop.
Get any country(German) datetime with summer/daylight time
/* Central European Time (UTC+01:00) - Sun, 29 Oct 2023 – Sun, 31 Mar 2024
Central European Summer Time (UTC+02:00) - Sun, 31 Mar, 2024 – Sun, 27 Oct, 2024
The code below converts the given date time to the actual time in the given time zone including summer/standard time differences.
*/
var summerTime = DateTime.Parse("31 Mar 2024");
var dayLightSavingTime = DateTime.Parse("1 Apr 2024");
var timeZone = "Central European Standard Time"; //Any timezone
Console.WriteLine(TimeZoneInfo.ConvertTimeFromUtc(summerTime,TimeZoneInfo.FindSystemTimeZoneById(timeZone))); //Output - [4/1/2024 2:00:00 AM]
Console.WriteLine(TimeZoneInfo.ConvertTimeFromUtc(dayLightSavingTime,TimeZoneInfo.FindSystemTimeZoneById(timeZone))); //Output - [3/31/2024 1:00:00 AM]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment