C#和PHP 长整型时间互转

        //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;
        }

 

posted @ 2018-07-12 22:53  软件技术开发  阅读(189)  评论(0编辑  收藏  举报