码迷,mamicode.com
首页 > 其他好文 > 详细

时间转换为Unix时间戳

时间:2016-12-29 17:00:38      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:datetime   alt   .text   task   ext   summary   div   pre   时间戳   

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时间戳

标签:datetime   alt   .text   task   ext   summary   div   pre   时间戳   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!