Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find time with millisecond using VBScript

Tags:

vbscript

I want to get time with millisecond Currently using Timer() method but it just give access upto second Any idea?

Please make sure i don't want to convert second into millisecond want to get with millisecond

like image 575
Mulesoft Developer Avatar asked Jan 30 '12 11:01

Mulesoft Developer


1 Answers

In fact Timer function gives you seconds with milliseconds. Integer part of returned value is the number of seconds since midnight and the fraction part can be converted into milliseconds - just multiply it by 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
like image 87
MBu Avatar answered Sep 20 '22 07:09

MBu