The benefit of this over FormatDate() is that this is UTC thus not affected by timezone/Daylight savings.
The resulting number is also human readable while also being machine readable something that is very important. You could use GetSystemTimeAsFileTime_() or some other API but these return nanoseconds since or milliseconds since or seconds since a epoch date, while machine readable those are not directly human readable as you need code to do calender calculations.
The resulting number can also be re-parsed into it's components fairly easily to get year and month and day for example, thus the number is very "portable".
In number form you need to store it as a 64bit number and in theory the max is um. well very high, GetSystemTime_() year in SYSTEMTIME structure maxes at 30827 and that can easily be contained in a 64bit integer.
In string form it may be a tad long (17 characters), but you could always base convert it to hex to shorten it (14 characters) if you want though.
Code: Select all
EnableExplicit
Procedure.q CurrentDateAsUTCNumber()
Protected st.SYSTEMTIME
GetSystemTime_(st)
ProcedureReturn (st\wYear*10000000000000)+(st\wMonth*100000000000)+(st\wDay*1000000000)+(st\wHour*10000000)+(st\wMinute*100000)+(st\wSecond*1000)+(st\wMilliseconds)
EndProcedure
Procedure.s CurrentDateAsUTCString()
ProcedureReturn Str(CurrentDateAsUTCNumber())
EndProcedure
Debug CurrentDateAsUTCNumber()
Debug CurrentDateAsUTCString()