And here's a nice human readable timestamp:
Comes in both a string and an integer64 version. Reading it is:
year
month
day
weekday (0 for sunday, 6 for saturday)
hour
minute
second
millisecond
Personally, I think this is a better method than the UTC Timestamps just because I -- as a human being -- can read and understand them with just one quick glance at them.
Code: (Select All)
Type SYSTIME
year As Integer
month As Integer
weekday As Integer
day As Integer
hour As Integer
minute As Integer
second As Integer
millis As Integer
End Type
Declare Dynamic Library "Kernel32"
Sub GetSystemTime (lpSystemTime As SYSTIME)
Sub GetLocalTime (lpSystemTime As SYSTIME)
End Declare
Dim st As SYSTIME
GetSystemTime st
Print st.year, st.month, st.day, st.weekday
Print st.hour, st.minute, st.second, st.millis
GetLocalTime st
Print st.year, st.month, st.day, st.weekday
Print st.hour, st.minute, st.second, st.millis
Do
_Limit 100
Locate 10, 1: Print " "; LocalTimeStamp$
Print LocalTimeStamp64
Loop Until _KeyHit = 27
Function LocalTimeStamp$
Dim st As SYSTIME
GetLocalTime st
t$ = AddString(t$, st.year, 4)
t$ = AddString(t$, st.month, 2)
t$ = AddString(t$, st.day, 2)
t$ = AddString(t$, st.weekday, 1)
t$ = AddString(t$, st.hour, 2)
t$ = AddString(t$, st.minute, 2)
t$ = AddString(t$, st.second, 2)
t$ = AddString(t$, st.millis, 3)
LocalTimeStamp = t$
End Function
Function LocalTimeStamp64~&&
Dim st As SYSTIME: GetLocalTime st
LocalTimeStamp64 = st.year * 1E14 + st.month * 1E12 + st.day * 1E10 + st.weekday * 1E9 + st.hour * 1E7 + st.minute * 1E5 + st.second * 1E3 + st.millis
End Function
Function AddString$ (what$, value As _Integer64, minDigits As Integer)
v$ = Right$(String$(minDigits, "0") + _Trim$(Str$(value)), minDigits)
AddString = what$ + v$
End Function
Comes in both a string and an integer64 version. Reading it is:
year
month
day
weekday (0 for sunday, 6 for saturday)
hour
minute
second
millisecond
Personally, I think this is a better method than the UTC Timestamps just because I -- as a human being -- can read and understand them with just one quick glance at them.