首页 > 代码库 > 时间转换为Unix时间戳

时间转换为Unix时间戳

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