C#和PHP 长整型时间互转

2021-03-29 11:24

阅读:695

标签:oca   datetime   date   var   ase   seconds   pre   val   add   

        //2018/5/14 16:03:05转换:1526284985

        public static double ConvertToDouble(DateTime date)
        {
            var baseTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
            var ts = date - baseTime;
            double intervel = ts.TotalSeconds;
            return intervel;
        }

        public static System.DateTime ConvertIntDateTime(double d)
        {
            System.DateTime time = System.DateTime.MinValue;
            System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
            time = startTime.AddSeconds(d);
            return time;
        }

 

C#和PHP 长整型时间互转

标签:oca   datetime   date   var   ase   seconds   pre   val   add   

原文地址:https://www.cnblogs.com/bqh10086/p/9302346.html


评论


亲,登录后才可以留言!