Page 1 of 1
Calculate Time zone
Posted: Nov 29th, ’18, 12:52
by asrey
I met the program 1 day ago and I love it!
A question: How to calculate the time of another country?
For example, I want to automatically put something like this: At this moment in China it is 9:30 p.m. and in Canada it is 3:30 p.m.
thank you!
Re: Calculate Time zone
Posted: Nov 30th, ’18, 07:48
by Marko
For a known time difference you can do something like this:
Type: Command
Code: Select all
TimeDifference:=-6
LocalTime:=A_Now
AltTime:=LocalTime
AltTime+=%TimeDifference%, Hours
FormatTime, LocalTime, %LocalTime%, Time
FormatTime, AltTime, %AltTime%, Time
Send, At this moment it is %LocalTime% here and %AltTime% in your country.
Re: Calculate Time zone
Posted: Nov 30th, ’18, 11:04
by asrey
It works perfect! is what I was looking for!
Could it be done with the days too?
For ex. When in a country it is 10 pm on November 29, in other countries it may be 1:00 am on November 30.
Then, I could show something like:
"At this moment it is 10:01 p.m. from November 29 here, and 01:01 a.m. from November 30 in your country"
thank you very much!
Re: Calculate Time zone
Posted: Dec 1st, ’18, 14:03
by Tom
Marko already gave a solution, you just need to adjust FormatTime command. There are many options:
https://autohotkey.com/docs/commands/FormatTime.htm
Code: Select all
TimeDifference:=-6
LocalTime:=A_Now
AltTime:=LocalTime
AltTime+=%TimeDifference%, Hours
FormatTime, ltime, %LocalTime%, Time
FormatTime, atime, %AltTime%, Time
FormatTime, ldate, %LocalTime%, MMMM d
FormatTime, adate, %AltTime%, MMMM d
Send, At this moment it is %ltime% from %ldate% here and %atime% from %adate% in your country.
Re: Calculate Time zone
Posted: Dec 3rd, ’18, 10:53
by asrey
Thank you very much Tom and Marko! It works perfectly!
Re: Calculate Time zone
Posted: Dec 9th, ’18, 16:38
by thinman
Great, thanks for this!