时间戳是指格林威治时间1970年01月01日00时00分00秒(北京时间1970年01月01日08时00分00秒)起至现在的总秒数。
时间戳转换的网址一大把,百度随便搜一下就有,比如:
http://tool.chinaz.com/Tools/unixtime.aspx
C#或者Java定义时间戳,一行代码搞定:
string timp = Convert.ToInt64((DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds).ToString();
想写明白点可以这样:
private string Stream()
{
TimeSpan tim = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(tim.TotalSeconds).ToString();
}
需要使用的时候直接调用函数就好了,这样:
Stream();
毫秒级时间戳:
long ts = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000;