Page 1 of 1

Simple Count Down timer and FormatTime weird behavior  Topic is solved

Posted: 21 Mar 2019, 22:20
by djvj11
I'm trying to figure out why when I put in to countdown 1800 seconds I get over 12 hrs of time counting down. But when I put in 2 hours (7200) it is correct? It's actually anything over 3600 seconds, once it reaches less than 1 hour left, it changes to 12 hours!

I noticed the hours becomes 00, which the format is converting it to 12 instead. How do I keep this as 0 and not show 12?

Code: Select all

#SingleInstance, force

; initSecs := 7200 ; number of seconds to wait
initSecs := 1800 ; number of seconds to wait

Gui, 99:+AlwaysOnTop +Disabled -SysMenu +Owner
Gui, 99:Font,s20 bold,Verdana
Gui, 99:Add, Text, w140 vTX , %initSecs%
Gui, 99:Show
Gui, 99:Flash

loop % initSecs-1 {        
    GuiControl,99:,TX,% Frmt(--initSecs)
    sleep, 1000
}
Gui, 99:Destroy

return

Frmt(secs) {
    time = 20000101
    time += %secs%, seconds
    FormatTime, hmmss, %time%, h:mm:ss
    return hmmss
}

esc::
ExitApp
NM, I got it, it was the 12-hr format, once I put HH instead of hh, it shows 00 instead!

Re: Simple Count Down timer and FormatTime weird behavior

Posted: 23 Mar 2019, 10:13
by lvalkov
Modify your formatting template to H:mm:ss.