q:: FormatTime, wedding, 201212081500 Formattime, %timeleft%, CurrentDate FormatTime, today, CurrentDateTime timeleft:=%wedding%-%today% Msgbox, %wedding% is our wedding date and it is currently %today% the time left is %timeleft% sleep, 60000 exitapp ;
Help with a countdown that is far away
Posted 14 April 2012 - 07:22 PM
Posted 14 April 2012 - 08:55 PM
W := 20121208150000 ; the wedding date ; some formatting for display: FormatTime today,, LongDate FormatTime wedding, %W%, LongDate ; now calculate the difference in days: EnvSub W, %A_Now%, Days ; EnvSub is capable of calculating time units ; Display: MsgBox %W% days left from today (%today%) to wedding (%wedding%).
Posted 14 April 2012 - 09:10 PM
Welcome to the AutoHotkey community forums.
The help files on EnvSub seem to have a suitable example to serve as a guideline for your project.
EnvSub, MyCount, 2
MyCount -= 2 ; Equivalent to above
var1 = 20050126
var2 = 20040126
EnvSub, var1, %var2%, days
MsgBox, %var1% ; The answer will be 366 since 2004 is a leap year.
<!-- m -->http://www.autohotke...ands/EnvSub.htm<!-- m -->
To find the current date in the same format as in the example, simply declare the variable to hold the current date like this:
CurrentDate := A_YYYY . A_MM . A_DD
Or like this:
CurrentDate = %A_YYYY%%A_MM%%A_DD%
And good luck on the big day :wink:
Posted 14 April 2012 - 09:29 PM
The reason why your script wasn't working is that the formattime command converts the date to a format
that people understand, but your timeleft calculation fails because AHk doesn't understand that format.
Also, there is no 'CurrentDate' variable; the closest is 'a_now'
The other user's already gave you sufficient information but I just had to chime in too
This one is for the bachelor chaps in your crowd.
Don't let the mis' see this one or you won'y need the script at all.
weddate=201212081500 daysleft := weddate daysleft -= %a_now%, days hoursleft := weddate hoursleft -= %a_now%, hours minutesleft := weddate minutesleft -= %a_now%, minutes secondsleft := weddate secondsleft -= %a_now%, seconds FormatTime, wedding, %weddate% FormatTime, today, a_now Msgbox, ( Our wedding date is %wedding% and since it is currently %today% the time left is %daysleft% days That's only %hoursleft% hours of freedom That's only %minutesleft% minutes of freedom That's only %secondsleft% seconds of freedom )
Posted 14 April 2012 - 10:44 PM
Kissinger not included joking
Posted 15 April 2012 - 03:28 AM