这里直接上代码
懂C# 的程序猿 一看便知道如何使用的...
/// <summary>
/// 将Unix时间戳转换为DateTime类型时间
/// </summary>
/// <param name="d">double 型数字</param>
/// <returns>DateTime</returns>
public static System.DateTime ConvertIntDateTime(double d)
{
System.DateTime time = System.DateTime.MinValue;
System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(, , ));
time = startTime.AddMilliseconds(d);
return time;
}
/// <summary>
/// 将c# DateTime时间格式转换为Unix时间戳格式
/// </summary>
/// <param name="time">时间</param>
/// <returns>long</returns>
public static long ConvertDateTimeInt(System.DateTime time)
{
//double intResult = 0;
System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(,,,,,,));
//intResult = (time- startTime).TotalMilliseconds;
long t = (time.Ticks - startTime.Ticks)/; //除10000调整为13位
return t;
}
本文转自:http://yfnk.net/a/wenzhangzhongxin/2013/0415/22.html