ExtensionMethod.NET Home of 875 C#, Visual Basic, F# and Javascript extension methods

CurrentDateTimeInAmsterdam

Get the current date time in Amsterdam

Source

public static DateTime CurrentDateTimeInAmsterdam(this DateTime date)
{
   TimeZoneInfo localZone = 
TimeZoneInfo.FindSystemTimeZoneById("W. Europe Standard Time");
   DateTime localTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, localZone);

   return localTime;
}

Example

label1.Text = new DateTime().TimeInAmsterdam().ToString();

Author: Marc van Steijn

Submitted on: 22 nov 2016

Language: C#

Type: DateTime

Views: 3613