To Utc - CSharp System

CSharp examples for System:DateTime UTC

Description

To Utc

Demo Code

// Copyright (c) Source Tree Solutions, LLC. All rights reserved.
using System.Globalization;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System;/*from   www. j a  va 2 s . com*/

public class Main{
        public static DateTime ToUtc(this DateTime localDate, TimeZoneInfo timeZone)
        {
            //return TimeZoneInfo.ConvertTimeToUtc(localDate, timeZone);

            return TimeZoneInfo.ConvertTime(DateTime.SpecifyKind(localDate, DateTimeKind.Local), TimeZoneInfo.Utc);
        }
}

Related Tutorials