Adding / Increment time in AutoHotkey: Adding Days, Hours, Minutes

I always stayed away from trying to “do math” on time as it was very confusing to me.  Maestrith, author of AHK studio, gave me a quick tutorial and demonstrated just how easy it is.  Check out this short video showing how easy it is to increment time in AutoHotkey.

Script demonstrating how to Increment time in AutoHotkey

#SingleInstance,Force
;Browser_Forward::Reload ;RControl::
;Browser_Back::
;**************************************
Days_Increment:=1
Hour_Increment:=1
Minute_Increment:=20
New_times:="Days`tHrs`tMin`tNew time`n"
loop, 10 {	
	Time:=A_Now ;Store current time
	Time+=Day_Offset,Days ;d=Days
	Time+=Hour_Offset,hours ;Add Hour offset to Time.  Also h=hours
	Time+=Minute_Offset,minutes ;Add minutes to Time.  Also m=minutes 
	FormatTime,New_Time,%Time%,MM/dd/yyyy h:mm tt ;format the "now" variable and set it in to New_Time
	New_Times.=Day_Offset a_tab Hour_Offset a_tab Minute_Offset a_tab New_Time "`n"
	;********************Increment Offset Time***********************************
	Day_Offset+=Days_Increment ; Add days	
	Hour_Offset+=Hour_Increment ;Add Hours
	Minute_Offset+=Minute_Increment ;Add minutes
}
DebugWindow(New_times,Clear:=1,LineBreak:=1,Sleep:=500,AutoHide:=0)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.