Format time with concatenation.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Marvin1023
Posts: 45
Joined: 10 Nov 2015, 12:49

Format time with concatenation.

03 May 2016, 11:48

Hi,

i use this code for add or remove time with EnvAdd

But the time format is not good in msgbox.
I need only HH:mm:ss FormatTime

Code: Select all

TIME_NOW_1 += -3, Hours 
TIME_NOW_2 += -2, Hours
TIME_NOW_3 += -1, Hours
TIME_NOW_4 += 0, Hours
TIME_NOW_5 += +1, Hours
TIME_NOW_6 += +2, Hours
TIME_NOW_7 += +3, Hours
   
Loop, 7
  {
   LOOP_NUMBER += 1
   MsgBox, % TIME_NOW_%LOOP_NUMBER%
  }
Return
Result:

Code: Select all

20160503154800
when I add FormatTime no change in msgbox :/

Thank for your help
Asus Maximus VIII Extrême - DDR4 16Go - Intel Core i7 - GTX 1080
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Format time with concatenation.

03 May 2016, 12:50

Code: Select all

TIME_NOW_1 += -3, Hours 
TIME_NOW_2 += -2, Hours
TIME_NOW_3 += -1, Hours
TIME_NOW_4 += 0, Hours
TIME_NOW_5 += 1, Hours
TIME_NOW_6 += 2, Hours
TIME_NOW_7 += 3, Hours
 
Loop, 7
{
    FormatTime, TIME_NOW_%A_Index%, % TIME_NOW_%A_Index%, HH:mm:ss
    MsgBox, % TIME_NOW_%A_Index%
}
Return
garry
Posts: 3760
Joined: 22 Dec 2013, 12:50

Re: Format time with concatenation.

03 May 2016, 15:19

thank you , just in case if you want 1 msgbox

Code: Select all

#warn
Loop, 7
  time_now_%a_index%:=""
e:=""

TIME_NOW_1 += -3, Hours
TIME_NOW_2 += -2, Hours
TIME_NOW_3 += -1, Hours
TIME_NOW_4 += 0, Hours
TIME_NOW_5 += 1, Hours
TIME_NOW_6 += 2, Hours
TIME_NOW_7 += 3, Hours

Loop, 7
{
    FormatTime, h_%A_Index%, % TIME_NOW_%A_Index%, HH:mm:ss
    aa:= h_%A_Index%
    e .= "TIME_NOW_" . a_index . "=" . aa . "`n"
}
msgbox,%e%
exitapp

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mikeyww, OrangeCat, roysubs, ShatterCoder and 93 guests