vb.net 如何获取当前时间戳
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14294156/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get current timestamp
提问by Dan
I am connecting to an API and one of the parameters is Long (13 digits)to hold the current timestamp
in VB.Net which represents milliseconds passed from 0:00:00 01.01.1970 in GMT
until
the current time.
我正在连接到一个 API,其中一个参数是 Long (13 位数字)来保存timestamp
VB.Net 中的电流,它表示从0:00:00 01.01.1970 in GMT
当前时间过去的毫秒数。
The format should be like this 1290932238757
格式应该是这样的 1290932238757
I tried this syntex :
我试过这个语法:
DirectCast((Datetime.Now - New DateTime(1970, 1, 1)).TotalMilliseconds, Int64)
But the output was :
但输出是:
01/12/2013 02:06:24
回答by keyboardP
If I understand correctly, does this work?
如果我理解正确,这行得通吗?
Dim milliseconds = CLng(DateTime.UtcNow.Subtract(New DateTime(1970, 1, 1))
.TotalMilliseconds)
I've used DateTime.UtcNow
in the example, but you can use DateTime.Now
depending on how you plan on using the data. See this threadfor more information on the difference.
我DateTime.UtcNow
在示例中使用过,但您可以DateTime.Now
根据您计划如何使用数据来使用。有关差异的更多信息,请参阅此线程。