Converts epoch time representation to DateTime object. - CSharp System

CSharp examples for System:DateTime Convert

Description

Converts epoch time representation to DateTime object.

Demo Code

// Copyright (c) Microsoft Corporation. All rights reserved. 
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*w ww.  j a v  a  2  s  .  c  o m*/

public class Main{
        /// <summary>
        /// Converts epoch time representation to DateTime object.
        /// </summary>
        /// <param name="epochInterval">EpochTime representation.</param>
        /// <returns>DateTime object.</returns>
        public static DateTime ConvertFromEpochTime(this ulong epochInterval)
        {
            return new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddSeconds(epochInterval);
        }
}

Related Tutorials