Discussion, questions and support.
-
asrey
- Posts: 5
- Joined: Nov 29th, ’18, 12:07
Post
by asrey » Nov 29th, ’18, 12:52
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!
-
Marko
- Posts: 1925
- Joined: Mar 2nd, ’13, 21:02
Post
by Marko » Nov 30th, ’18, 07:48
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.
-
asrey
- Posts: 5
- Joined: Nov 29th, ’18, 12:07
Post
by asrey » Nov 30th, ’18, 11:04
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!
-
Tom
- Posts: 917
- Joined: Nov 24th, ’15, 23:39
Post
by Tom » Dec 1st, ’18, 14:03
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.
-
asrey
- Posts: 5
- Joined: Nov 29th, ’18, 12:07
Post
by asrey » Dec 3rd, ’18, 10:53
Thank you very much Tom and Marko! It works perfectly!
-
thinman
- Posts: 31
- Joined: May 17th, ’13, 15:44
Post
by thinman » Dec 9th, ’18, 16:38
Great, thanks for this!