使用VBScript查找毫秒的时间

Riz*_*hid 10 vbscript

我希望得到毫秒的时间目前使用Timer()方法,但它只提供访问最多任何想法?

请确保我不想将秒转换为毫秒,希望得到毫秒

MBu*_*MBu 16

实际上,Timer函数为您提供毫秒的秒数.返回值的整数部分是自午夜以来的秒数,小数部分可以转换为毫秒 - 只需将其乘以1000即可.

t = Timer

' Int() behaves exactly like Floor() function, i.e. it returns the biggest integer lower than function's argument
temp = Int(t)

Milliseconds = Int((t-temp) * 1000)

Seconds = temp mod 60
temp    = Int(temp/60)
Minutes = temp mod 60
Hours   = Int(temp/60)

WScript.Echo Hours, Minutes, Seconds, Milliseconds

' Let's format it
strTime =           String(2 - Len(Hours), "0") & Hours & ":"
strTime = strTime & String(2 - Len(Minutes), "0") & Minutes & ":"
strTime = strTime & String(2 - Len(Seconds), "0") & Seconds & "."
strTime = strTime & String(4 - Len(Milliseconds), "0") & Milliseconds

WScript.Echo strTime
Run Code Online (Sandbox Code Playgroud)