Convert a unix timestamp to the corresponding datetime. - CSharp System

CSharp examples for System:DateTime Unix

Description

Convert a unix timestamp to the corresponding datetime.

Demo Code


using System;/*from w w w.  j a va 2s  .co m*/

public class Main{
        /// <summary>
        /// Convert a unix timestamp to the corresponding datetime.
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static DateTime FromUnixTime(double value)
        {
            DateTime unixStart = new DateTime(1970, 1, 1, 0, 0, 0, 0);
            return unixStart.AddSeconds(value);
        }
}

Related Tutorials