标签:
时间戳是全世界统一的,对应世界时(UniversalTime);本地时间对应LocalTime;
public static string GetTimeStamp( DateTime date) { TimeSpan ts = date.ToUniversalTime() - new DateTime( 1970, 1 , 1, 0, 0 , 0, 0); var ret = Convert. ToInt64(ts.TotalSeconds) .ToString(); return ret; }
public static DateTime FROM_UNIXTIME( long timeStamp) { return DateTime .Parse("1970-01-01 00:00:00" ).AddSeconds(timeStamp) .ToLocalTime(); }
标签:
原文地址:http://www.cnblogs.com/defoliate/p/4379920.html