Convert UTC time, as returned by Facebook, to localtime. - CSharp System

CSharp examples for System:DateTime UTC

Description

Convert UTC time, as returned by Facebook, to localtime.

Demo Code


using System;// www. j a v  a2 s.co m

public class Main{
        /// <summary>
        /// Convert UTC time, as returned by Facebook, to localtime.
        /// </summary>
        /// <param name="secondsSinceEpoch">The number of seconds since Jan 1, 1970.</param>
        /// <returns>Local time.</returns>
        internal static DateTime ConvertDoubleToDate(double secondsSinceEpoch) {
            TimeZone localZone = TimeZone.CurrentTimeZone;
            DateTime utcdate = new DateTime(1970, 1, 1, 0, 0, 0).AddSeconds(secondsSinceEpoch);
            DateTime localTime = localZone.ToLocalTime(utcdate);

            return localTime;
        }
}

Related Tutorials