Get TimeZone time from Google Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
rc76
Posts: 145
Joined: 07 Nov 2020, 01:45

Get TimeZone time from Google

23 Oct 2021, 09:06

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:
00.png
00.png (135.72 KiB) Viewed 1269 times
User avatar
mikeyww
Posts: 26931
Joined: 09 Sep 2014, 18:38

Re: Get TimeZone time from Google  Topic is solved

23 Oct 2021, 09:21

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
}
rc76
Posts: 145
Joined: 07 Nov 2020, 01:45

Re: Get TimeZone time from Google

23 Oct 2021, 21:29

This works perfectly! Thank you @mikeyww
KingPresLii
Posts: 13
Joined: 29 May 2022, 16:20

Re: Get TimeZone time from Google

02 Aug 2022, 06:52

mikeyww wrote:
23 Oct 2021, 09:21

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
}
this only gives time, how to show date like september 6, 2022. please?
User avatar
mikeyww
Posts: 26931
Joined: 09 Sep 2014, 18:38

Re: Get TimeZone time from Google

02 Aug 2022, 07:11

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
}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Araphen, Bobak, mapcarter and 306 guests