vb.net 获取unix时间戳
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13534670/
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
Getting unix timestamp
提问by Scott
Its a pretty simple question but I couldnt find nothing about it.
这是一个非常简单的问题,但我什么也找不到。
I would like to get the current unix timestamp in seconds, I would like to get the identical result as the PHP's time()function.
我想以秒为单位获取当前的 unix 时间戳,我想获得与 PHPtime()函数相同的结果。
System.Nowreturns full date with the current time.
System.Now返回当前时间的完整日期。
How can I achieve this in vb.net?
我怎样才能在 vb.net 中实现这一点?
回答by Rolf Bjarne Kvinge
I belive this will do it:
我相信这会做到:
Public Shared Function GetUnixTimestamp () As Double
Return (DateTime.Now - new DateTime (1970, 1, 1, 0, 0, 0, 0)).TotalSeconds
End Function

