To Pacific Time - CSharp System

CSharp examples for System:DateTime Timezone

Description

To Pacific Time

Demo Code


using System.Threading.Tasks;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*w  w w  . ja v  a2 s .c o m*/

public class Main{
        public static DateTime ToPacificTime(this DateTime dateTime)
        {
            return TimeZoneInfo.ConvertTimeFromUtc(dateTime, Pacific);
        }
        public static DateTime? ToPacificTime(this DateTime? dateTime)
        {
            if (dateTime == null)
            {
                return null;
            }
            return ToPacificTime(dateTime.Value);
        }
}

Related Tutorials