[.Net]將時間轉換成TimeStamp
參考網路上文章,自己做個筆記方便以後快速查詢:
public double DateTimeToUnixTimestamp(DateTime dateTime)
{
return (TimeZoneInfo.ConvertTimeToUtc(dateTime) -
new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc)).TotalSeconds;
}
參考文章:
How to convert a Unix timestamp to DateTime and vice versa?
http://stackoverflow.com/questions/249760/how-to-convert-a-unix-timestamp-to-datetime-and-vice-versa