I understand there is way to compute the time for specific timezone by manually add/minus UTC time.
However there are cases with Day Light Savings, and its rules may change from time to time.
I am wondering, whether it is possible to compute the time for a specific city/timezone directly from Internet/Google?
For example:
Get TimeZone time from Google Topic is solved
Re: Get TimeZone time from Google Topic is solved
Code: Select all
MsgBox, 64, Tokyo time , % time("Asia/Tokyo")
MsgBox, 64, New York time, % time("America/New_York")
time(area) {
WinHttp := ComObjCreate("WinHttp.WinHttpRequest.5.1")
WinHttp.Open("GET", "http://worldtimeapi.org/api/timezone/" area, false), WinHttp.Send()
RegExMatch(WinHttp.ResponseText, """datetime"":.+?T\K[\d:]+", time)
Return time
}
Re: Get TimeZone time from Google
This works perfectly! Thank you @mikeyww
-
- Posts: 13
- Joined: 29 May 2022, 16:20
Re: Get TimeZone time from Google
this only gives time, how to show date like september 6, 2022. please?mikeyww wrote: ↑23 Oct 2021, 09:21Code: Select all
MsgBox, 64, Tokyo time , % time("Asia/Tokyo") MsgBox, 64, New York time, % time("America/New_York") time(area) { WinHttp := ComObjCreate("WinHttp.WinHttpRequest.5.1") WinHttp.Open("GET", "http://worldtimeapi.org/api/timezone/" area, false), WinHttp.Send() RegExMatch(WinHttp.ResponseText, """datetime"":.+?T\K[\d:]+", time) Return time }
Re: Get TimeZone time from Google
Code: Select all
tokyo := dateTime("Asia/Tokyo")
ny := dateTime("America/New_York")
MsgBox, 64, Tokyo time , % dateFix(tokyo.date) "`n`nat`n`n" tokyo.time
MsgBox, 64, New York time, % dateFix(ny.date) "`n`nat`n`n" ny.time
dateTime(area) {
WinHttp := ComObjCreate("WinHttp.WinHttpRequest.5.1")
WinHttp.Open("GET", "http://worldtimeapi.org/api/timezone/" area, false), WinHttp.Send()
RegExMatch(WinHttp.ResponseText, """datetime"":""([\d-]+)T([\d:]+)", m)
Return {date: m1, time: m2}
}
dateFix(date) {
FormatTime, date, % StrReplace(date, "-"), MMMM d, yyyy
Return date
}