using System;
using System.Collections.Generic;
using System.Text; namespace TJCFinanceWriteOff.BizLogic.Common
{
public class UnixTimeUtil
{
/// <summary>
/// 将dateTime格式转换为Unix时间戳
/// </summary>
/// <param name="time"></param>
/// <returns></returns>
public static string ConvertDateTimeToUnix(DateTime time)
{
return ((time.ToUniversalTime().Ticks - ) / ).ToString();
} /// <summary>
/// 将Unix时间戳转换为dateTime格式
/// </summary>
/// <param name="unix"></param>
/// <returns></returns>
public static DateTime ConvertUnixToDateTime(string unix)
{
DateTime startUnixTime = System.TimeZoneInfo.ConvertTime(new DateTime(, , , , , , DateTimeKind.Utc), TimeZoneInfo.Local);
return startUnixTime.AddSeconds(double.Parse(unix));
}
}
}