Subject: RE: function equal to java System.currentTimeMillis()?
If you happen to be using Win/32, you can use “GetLocalTime” as follows:
Public Type sysTimeTYPE
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
Declare Sub W32GetLocalTime Lib “kernel32” Alias “GetLocalTime” ( _
lpSystemTime As sysTimeTYPE
)
Dim localtime As sysTimeTYPE
Dim strMsgTxt As String
Call W32GetLocalTime(localtime)
strMsgTxt$ = _
"Year: " & localtime.wYear & Chr(13) _
& "Month: " & localtime.wMonth & Chr(13) _
& "Day of week: " & localtime.wDayOfWeek & Chr(13) _
& "Day: " & localtime.wDay & Chr(13) _
& "Hour: " & localtime.wHour & Chr(13) _
& "Minute: " & localtime.wMinute & Chr(13) _
& "Second: " & localtime.wSecond & Chr(13) _
& "Millisecond: " & localtime.wMilliseconds
Msgbox strMsgTxt$, , “Results . . .”
But a more platform independent option is to use Getthreadinfo:
Const LSI_THREAD_TICKS_PER_SEC = 7 '// see lsprcval.lss
Const LSI_THREAD_TICKS = 6 '// see lsprcval.lss
Dim dblTickCount As Double
Dim intTicksPerSecond As Integer
intTicksPerSecond% = Getthreadinfo(LSI_THREAD_TICKS_PER_SEC)
dblTickCount# = Getthreadinfo(LSI_THREAD_TICKS)
Print "Ticks per second: " & intTicksPerSecond%
Print "Ticks lapsed: " & dblTickCount# '// on Win/32, this is essentially milliseconds but other platforms differ
Print "Seconds lapsed: " & dblTickCount# / intTicksPerSecond%
Print "Minutes lapsed: " & (dblTickCount# / intTicksPerSecond%) / 60
Print "Hours lapsed: " & (dblTickCount# / intTicksPerSecond%) / (60^2)
On Windows, the above code reports ticks lapsed since the current machine was started.
hth,
dgg