首页 > 其他 > 详细

时间转换为Unix时间戳

时间:2016-12-29 16:59:31      阅读:186      评论:0      收藏:0      [点我收藏+]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Common
{
    public class DateUtils
    {
        /// <summary>
        /// 时间转换为Unix时间戳
        /// </summary>
        /// <param name="date"></param>
        /// <returns></returns>
        public static int DateConvertToInt(DateTime date)
        {
            DateTime newDate = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970,1,1));
            return (int)(date - newDate).TotalSeconds;
        }
    }
}

 

时间转换为Unix时间戳

原文:http://www.cnblogs.com/Jacob-Wu/p/6233116.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!