开发者

Equivalent to Java's System.currentTimeMillis() in .NET?

开发者 https://www.devze.com 2023-04-01 20:52 出处:网络
Is there a .NETequivalent toJava\'s System.curre开发者_如何转开发ntTimeMillis()? I want to find the number of milliseconds since 1970.Dim epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)

Is there a .NET equivalent to Java's System.curre开发者_如何转开发ntTimeMillis()?

I want to find the number of milliseconds since 1970.


    Dim epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)
    Dim millis = CLng((DateTime.UtcNow - epoch).TotalMilliseconds)


Try the following

(DateTime.Now - New DateTime(1970, 1, 1)).TotalMilliseconds


Try the following function

(DateTime.UtcNow- New DateTime(1970, 1, 1)).TotalMilliseconds

will generate the exact value as System.CurrentMillis() in Java

Thanks for the answer of JaredPar

0

精彩评论

暂无评论...
验证码 换一张
取 消