Last active
August 1, 2020 20:14
-
-
Save daniellowtw/b1c6568198ca5991db4de8e1569ae20e to your computer and use it in GitHub Desktop.
Autohotkey RFC3339 datetime with timezone
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Usage: | |
timeStr := Get_now() | |
MsgBox, %timeStr | |
*/ | |
Get_now() | |
{ | |
global | |
UTCFormatStr := "yyyy-MM-dd'T'HH:mm:ss" | |
FormatTime, TimeStr, CurrentDateTime, %UTCFormatStr% | |
T1 := A_Now | |
T2 := A_NowUTC | |
EnvSub, T1, %T2%, M | |
TZD := Round( T1/60, 0 ) | |
if (TZD == "0") { | |
return Format("{}Z", TimeStr) | |
} else if (TZD < 0) { | |
return Format("{}-{2:02}:00", TimeStr, -TZD ) | |
} else { | |
return Format("{}+{2:02}:00", TimeStr, TZD ) | |
} | |
} | |
;Ctrl + Shift + D to add date time | |
^+d:: | |
FormatTime, CurrentDateTime, , dd/MM/yyyy | |
SendInput %CurrentDateTime% | |
return | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment