How to get Current Time in Millisecond
i am working with a winsock prog that send current time to server in millisecond
how do i convert time to millisecond i have no idea how my current time =1254193889061
1254193889061 <-- is my time few minutes ago
plz help me with converting time to millisecond !!
Re: How to get Current Time in Millisecond
Here's one way:
Code:
Option Explicit
Private Type SYSTEMTIME
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
Private Declare Sub GetSystemTime Lib "kernel32.dll" (lpSystemTime As SYSTEMTIME)
Private Declare Sub GetLocalTime Lib "kernel32.dll" (lpSystemTime As SYSTEMTIME)
Private Sub Form_Load()
Dim st As SYSTEMTIME
' GetSystemTime st GMT
GetLocalTime st
Debug.Print st.wMonth, st.wDay, st.wYear
Debug.Print st.wHour, st.wMinute, st.wSecond, st.wMilliseconds
End Sub
Re: How to get Current Time in Millisecond
It appears your time is based off of a start date of 1 Jan 1970. In that case, you can also do this without APIs. Value will be large, so Double variable type could be appropriate.
Code:
MsgBox DateDiff("s", CDate("1/1/1970"), Now()) * 1000#
' Edited: If regional settings and date formats are a concern, use hardcoded value for 1/1/1970
MsgBox DateDiff("s", 25569#, Now()) * 1000#