QA Graphic

Milliseconds to Seconds Converter

Quickly calculate Milliseconds to Seconds

This is a quick Macro that will activate when I need to convert the number on the clipboard (Milliseconds) to seconds.

In Action...

I simply select the value, then type in my trigger action keys: .mill then the value gets typed in.

So 23893 will become 0:24 - you can configure this so that it can output whatever format works for you.

Keyboard Maestro Script

Milliseconds

The Javascript that I used for the calculations:

var app = Application.currentApplication()
app.includeStandardAdditions = true
 
var kmInst = app.systemAttribute("KMINSTANCE");
var kmeApp = Application("Keyboard Maestro Engine")
 
var myLocalVar = kmeApp.getvariable("Local__MyVar",  {instance: kmInst});
kmeApp.setvariable("Local__FromJXA", {instance: kmInst, to: "Set in JXA Script"})
function millisToMinutesAndSeconds(millis) {
  var minutes = Math.floor(millis / 60000);
  var seconds = ((millis % 60000) / 1000).toFixed(0);
  return minutes + ":" + (seconds < 10 ? '0' : '') + seconds;
}
millisToMinutesAndSeconds(myLocalVar); // "4:59"

 

Comments

Add Comments

Name:
Comment:

 

About

These posts highlights some cool examples of why Keyboard Maestro should be part of every Mac OS user's computer. Keyboard Maestro is a powerful automation tool that can help improve productivity, save time, and streamline tedious tasks. It has a wide range of features and functions that can be customized to suit any user's needs, making it an ideal choice for Mac OS users.

Schedule

FridayMacintosh
SaturdayInternet Tools
SundayOpen Topic
Monday Media Monday
TuesdayQA
WednesdaySnagIt for QA
ThursdayPython