secondstohms
v1.2.5
Published
Package to convert seconds to time format (HH:MM:SS)
Downloads
11
Maintainers
Readme
secondstohms
This package converts seconds to a time format (HH:MM:SS) for initial few releases we are only going to return HH:MM:SS format but for later releases we can send different formats to the client
how to use this package:
📦 Install
npm install secondstohms
yarn add secondstohms
🔨 Usage
convertSecondsToHMS: currently we only have one method to require
const { convertSecondsToHMS } = require("secondstohms");
const hms = convertSecondsToHMS(3600);
// displays 01 : 00 : 00
console.log(hms);
// second boolean argument is to get hours and minutes and seconds in an object
// for easy access to separate values
const hms_duplicate = convertSecondsToHMS(9581, true);
// displays { hours: 2, minutes: 39, seconds: 41 }
console.log(hms_duplicate);
🔨 Usage in modules
import { convertSecondsToHMS } from "secondstohms";
const hms = convertSecondsToHMS(3600);
// displays 01 : 00 : 00
console.log(hms);
// second boolean argument is to get hours and minutes and seconds in an object
// for easy access to separate values
const hms_duplicate = convertSecondsToHMS(9581, true);
// displays { hours: 2, minutes: 39, seconds: 41 }
console.log(hms_duplicate);
🔨 To get hours and minutes separately
can be used as javascript modules as shown below
import { convertToHours, convertToMinutes } from "secondstohms";
const hours = convertToHours(7200);
const minutes = convertToMinutes(7200);
// displays 2 (2 hours)
console.log(hours);
// displays 120 (120 minutes)
console.log(minutes);
publisher
Mantiqh Technologies