thank you 謝謝 tmplinshi
another example from user justme
Code: Select all
;- http://www.autohotkey.com/board/topic/89516-iso-8601formatting-datetime/
;- from user just me
#NoEnv
SetBatchLines, -1
;- example-1 --
UTC := GetTimestampUTC()
Beijing1 := GetTimestampUTC()
Beijing1 += 8, Hours
;- example-2 --
Beijing2 := % BeijingTime()
;- http://www.science.co.il/language/locale-codes.asp
FormatTime, China , %Beijing1% L2052, dddd MMMM yyyy-MM-dd
FormatTime, Hong_Kong , %Beijing1% L3076, dddd MMMM yyyy-MM-dd
FormatTime, Macau , %Beijing1% L5124, dddd MMMM yyyy-MM-dd
FormatTime, Singapore , %Beijing1% L4100, dddd MMMM yyyy-MM-dd
FormatTime, Taiwan , %Beijing1% L1028, dddd MMMM yyyy-MM-dd
msgbox, 262208,Time China ,UTC =%utc%`nChina-1=%Beijing1%`nChina-2=%Beijing2%`nChina=%china%`nHong_Kong=%Hong_Kong%`nMacao=%Macau%`nSingapore=%Singapore%`nTaiwan=%Taiwan%
ExitApp
;- example-1 just-me --
GetTimestampUTC() { ; http://msdn.microsoft.com/en-us/library/ms724390
VarSetCapacity(ST, 16, 0) ; SYSTEMTIME structure
DllCall("Kernel32.dll\GetSystemTime", "Ptr", &ST)
Return NumGet(ST, 0, "UShort") ; year : 4 digits until 10000
. SubStr("0" . NumGet(ST, 2, "UShort"), -1) ; month : 2 digits forced
. SubStr("0" . NumGet(ST, 6, "UShort"), -1) ; day : 2 digits forced
. SubStr("0" . NumGet(ST, 8, "UShort"), -1) ; hour : 2 digits forced
. SubStr("0" . NumGet(ST, 10, "UShort"), -1) ; minute : 2 digits forced
. SubStr("0" . NumGet(ST, 12, "UShort"), -1) ; second : 2 digits forced
}
;- example-2 tmplinshi --
;-------- http://ahkscript.org/boards/viewtopic.php?f=28&t=3408 ---
BeijingTime() { ; ?? YYYYMMDDHHMISS
Http := ComObjCreate("WinHttp.WinHttpRequest.5.1")
Http.Open("HEAD", "http://baidu.com", True)
Http.Send()
Http.WaitForResponse(-1)
_Date := Http.GetResponseHeader("Date")
; Mon, 21 Apr 2014 14:58:23 GMT
Obj := StrSplit( _Date, [A_Space, ":"] )
Months := "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec"
Mon := SubStr( "0" Ceil( Instr(Months, Obj.3) / 4 ), -1 )
; YYYYMMDDHHMISS
_Date := Obj.4 Mon Obj.2 Obj.5 Obj.6 Obj.7
; add 8
_Date += 8, Hours
Return _Date
}