1. 程式人生 > >c# timestamp轉換datetime

c# timestamp轉換datetime

一、Codes

class Program
{
    static void Main(string[] args)
    {
        var result = UnixTimeStampToDateTime(1497528525420);
    }
    public static DateTime UnixTimeStampToDateTime(double unixTimeStamp)
    {
        var dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
        dtDateTime 
= dtDateTime.AddMilliseconds(unixTimeStamp).ToLocalTime(); return dtDateTime; } }

 

二、Result