Skip to content

Instantly share code, notes, and snippets.

@daniellowtw
Last active August 1, 2020 20:14
Show Gist options
  • Save daniellowtw/b1c6568198ca5991db4de8e1569ae20e to your computer and use it in GitHub Desktop.
Save daniellowtw/b1c6568198ca5991db4de8e1569ae20e to your computer and use it in GitHub Desktop.
Autohotkey RFC3339 datetime with timezone
/*
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