This converts current timestamp to Unix:
Code: Select all
GetUnixTimestamp(){
NowUTC := A_NowUTC
NowUTC -= 19700101000000, S
return NowUTC
}
Code: Select all
GetUnixTimestamp(){
NowUTC := A_NowUTC
NowUTC -= 19700101000000, S
return NowUTC
}
Code: Select all
orig := A_Now, unix := GetUnixTimestamp(), local := unixToLocalTime(unix)
MsgBox, 64, Times, % "`n`nUnix = " unix "`nOrig = " orig "`nLocal = " local
ExitApp
GetUnixTimestamp(){
NowUTC := A_NowUTC
NowUTC -= 1970, S
Return NowUTC
}
unixToLocalTime(unix) {
; @mikeyww on 23 October 2020
; https://www.autohotkey.com/boards/viewtopic.php?f=76&t=82405
; https://autohotkey.com/board/topic/2486-code-to-convert-fromto-unix-timestamp/
out = %TEMP%\unixToLocalTime.tmp
RunWait, %A_ComSpec% /c "%A_WinDir%\System32\w32tm.exe /tz >%out%",, Hide
FileRead, timeOutput, %out%
FileDelete, %out%
NowLocal := 1970
NowLocal += unix, s
RegExMatch(timeOutput, "(DAYLIGHT) Bias: (-?\d+)min", dst)
NowLocal += 60 * (dst1 = "DAYLIGHT") - dst2, Minutes
Return NowLocal
}
Code: Select all
unixTime := 1603435790
time := 1970
time += unixTime, s
utcTime := time
diff -= A_NowUTC, h
time += diff, h
localTime := time
MsgBox, % "utc: " . utcTime . "`nlocal: " . localTime
Code: Select all
UnixToUTC(unixTime){
time:=1970
time+=unixTime, s
return time
}
Users browsing this forum: Bing [Bot], Google [Bot], jeves and 144 guests