New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

sec-to-format

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sec-to-format

Convert unix timestamp seconds to readable time format.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

Convert Seconds to Readable Format

npm version Build Status

$ npm i sec-to-format --save

Usage

import secToFormat from 'sec-to-format';
secToFormat(3601, '%H hour %s sec');
// 1 hour 1 sec
secToFormat(90643, '%D day %H hour %m minutes %s secs');
// 1 day 1 hour 10 minutes 43 secs
secToFormat(90643, '%D day %H:%m:%s');
// 1 day 1:10:43

Setters

You can manipulate outputs by adding setter to the units.

const setters = {
  '%H': hour => (hour < 10 ? `0${hour}` : hour),
  '%m': min => (min < 10 ? `0${min}` : min),
};

secToFormat(7300, '%H:%m:%s');
// 2:1:40

secToFormat(7300, '%H:%m:%s', { setters });
// 02:01:40

Unit Table

UnitDescription
%sSecond
%mMinute
%HHour
%DDay
%WWeek
%MMMonth
%YYear

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

Keywords

formatter

FAQs

Package last updated on 17 Nov 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts