$hNtDll = DllOpen("Ntdll.dll") $iSysTime = _NtQuerySystemTime($hNtdll) $iUnixTime = _RtlTimeToSecondsSince1970($iSysTime, $hNtdll) ConsoleWrite("System time: " & $iSysTime & @CRLF & _ "... in Unix time: " & $iUnixTime & @CRLF & _ "Another Unix Timestamp: " & _GetUnixTimestamp() & @CRLF) DllClose($hNtDll) ; #FUNCTION# ==================================================================================================================== ; Name ..........: _NtQuerySystemTime ; Description ...: Returns the system time in a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (UTC). ; Syntax ........: _NtQuerySystemTime([$_hNtdll = Default]) ; Parameters ....: $_hNtdll - [optional] Handle to an opened Ntdll.dll file. ; Return values .: Success - System time in a 64-bit integer. ; Failure - -1 and sets @error to 1. ; Author ........: name22 (www.autoit.de) ; Modified ......: ; Remarks .......: ; Related .......: _RtlTimeToSecondsSince1970 ; Link ..........: http://msdn.microsoft.com/en-us/library/windows/desktop/ms724512%28v=vs.85%29.aspx ; Example .......: Yes ; =============================================================================================================================== Func _NtQuerySystemTime($_hNtdll = Default) If $_hNtdll = Default Then $_hNtdll = "Ntdll.dll" $_aRet = DllCall($_hNtdll, "INT", "NtQuerySystemTime", "INT64*", "") If @error Then Return SetError(1, 0, -1) Return $_aRet[1] EndFunc ; #FUNCTION# ==================================================================================================================== ; Name ..........: _RtlTimeToSecondsSince1970 ; Description ...: Converts the specified 64-bit system time to the number of seconds since the beginning of January 1, 1970. ; Syntax ........: _RtlTimeToSecondsSince1970($_iTime[, $_hNtdll = Default]) ; Parameters ....: $_iTime - 64-bit integer specifying the time in 100 nanosecond intervals since January 1, 1601 (UTC). ; $_hNtdll - [optional] Handle to an opened Ntdll.dll file ; Return values .: Success - Converted Unix time. ; Failure - -1 and sets @error to 1. ; Author ........: name22 (www.autoit.de) ; Modified ......: ; Remarks .......: ; Related .......: _NtQuerySystemTime ; Link ..........: http://msdn.microsoft.com/en-us/library/windows/desktop/ms724928%28v=vs.85%29.aspx ; Example .......: Yes ; =============================================================================================================================== Func _RtlTimeToSecondsSince1970($_iTime, $_hNtdll = Default) If $_hNtdll = Default Then $_hNtdll = "Ntdll.dll" $_aRet = DllCall($_hNtdll, "BOOL", "RtlTimeToSecondsSince1970", "INT64*", $_iTime, "INT64*", "") If @error Then Return SetError(1, 0, -1) Return $_aRet[2] EndFunc ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GetUnixTimestamp ; Description ...: Returns the Unix Timestamp (or the number of seconds since January 1, 1970 according to system time). ; Syntax ........: _GetUnixTimestamp() ; Parameters ....: ; Return values .: Unix Timestamp. ; Author ........: name22 (www.autoit.de) ; Modified ......: ; Remarks .......: Not really necessary, since the code fits into one line. Mostly an example for retrieving the unix timestamp. ; Related .......: _NtQuerySystemTime, _RtlTimeToSecondsSince1970 ; Link ..........: http://en.wikipedia.org/wiki/Unix_time ; Example .......: Yes ; =============================================================================================================================== Func _GetUnixTimestamp() Return _RtlTimeToSecondsSince1970(_NtQuerySystemTime()) EndFunc