...
//DateTime轉換為時間戳
public long GetTimeSpan(DateTime time) { DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970,1,1,0,0,0,0));
return (long)(time - startTime).TotalSeconds; }
//timeSpan轉換為DateTime
public DateTime TimeSpanToDateTime(long span)
{
DateTime time = DateTime.MinValue;
DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970,1,1,0,0,0,0));
time=startTime.AddSeconds(span);
return time;
}