我正在连接一个 API,其中一个参数是 Long (13 位数字) 用于在 VB.Net 中保存当前 timestamp
,它表示从 0:00:00 01.01.1970 in GMT
至当前时间经过的毫秒数。
格式应该像这样 1290932238757
我尝试了以下语法:
DirectCast((Datetime.Now - New DateTime(1970, 1, 1)).TotalMilliseconds, Int64)
但是输出结果是:
01/12/2013 02:06:24
new Date(1,1,1970)
创建的日期是没有时区意识的。.ToUniversalTime
方法会将其转换为本地时间。最好的方法是创建有时区意识的日期:New DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc)
。 - Desmond