Convert minutes to hours and minutes.

Get help with using AutoHotkey and its commands and hotkeys
Posts: 103
Joined: 25 Nov 2016, 16:44

Convert minutes to hours and minutes.

27 Jul 2018, 18:44

My printer gives me time remaining in minutes, I am trying to convert that into hours and minutes. For instance if it tells me 90 minutes left I would like to convert it to 1:30. I've tried using FormatTime but I'm not doing something right.

Code: Select all

FormatTime, TimeVar, 90, h:mm
Since some prints take several days it may be beneficial to convert to days, hours and minutes. Any ideas on how to accomplish this?
User avatar
Posts: 6708
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Convert minutes to hours and minutes.

27 Jul 2018, 19:08

- FormatTime only accepts dates, starting at the year 1601, so normally you have to use something like 19000101 and apply EnvAdd/DateAdd and then format the date using FormatTime, if you want to use FormatTime to format times (durations) instead of dates.
- Here's a function that uses Format instead of FormatTime:

Code: Select all

q:: ;minutes to d:HH:mm or H:mm
MsgBox, % FormatMin(90)
MsgBox, % FormatMin(90 + 24*60)

	if (vMin < 1440)
		return Format("{}:{:02}", Floor(Mod(vMin,1440)/60), Floor(Mod(vMin,60)))
		return Format("{}:{:02}:{:02}", Floor(vMin/1440), Floor(Mod(vMin,1440)/60), Floor(Mod(vMin,60)))
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Posts: 103
Joined: 25 Nov 2016, 16:44

Re: Convert minutes to hours and minutes.

28 Jul 2018, 22:22

Great, thanks for this.

I had actually found a way using the old MCI library. It has a function to convert minutes to milliseconds and another to convert milliseconds to hours, minutes, and seconds. That worked but this is much simpler. Thanks again.

Return to “Ask For Help”

Who is online

Users browsing this forum: anaxio, Bing [Bot], takayo97 and 241 guests