Get Utc Time Assuming Zone - CSharp System

CSharp examples for System:DateTime Timezone

Description

Get Utc Time Assuming Zone

Demo Code


using System.Globalization;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*from www  .j  av a 2 s .c  o  m*/

public class Main{
        public static DateTime GetUtcTimeAssumingZone(this DateTime date, string timeZoneID)
        {
            return TimeZoneInfo.ConvertTimeToUtc(date, TimeZoneInfo.FindSystemTimeZoneById(timeZoneID));
        }
}

Related Tutorials