New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ms-time-tools

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ms-time-tools

ms-time-tools is a powerful Node.js module that allows you to easily manage time.

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

About

ms-time-tools is a powerful Node.js module that allows you to easily manage time.

Features

  • Installation
  • Convert from milliseconds
  • Convert from string

Installation

npm install --save ms-time-tools

Examples

const  mtt = require('ms-times-tools'); // Import the module

Convert from milliseconds

Here is the list of all the arguments available:

ParameterTypeOptionalDefaultDescription
timenumberTime in milliseconds to convert into string
formatstringY-MO-W-D-H-M-S-MSFormat and order of time returned
langstringenLanguage of time unities
longbooleanfalseReturns the whole word (not abbreviations)
separatorstring,Separators of time values
suppressTagbooleanfalseReturns time without unities
valueNullbooleanfalseRemoves values equal to zero

Some usage examples:

mtt.stringifyTime(61000); // 1m, 1s

mtt.stringifyTime(
    617780000,
	{
	    format: 'Y-MO-W-D-H-M-S-MS',
		lang: 'en',
		long: true
	}
); // 1 week, 3 hours, 36 minutes, 20 seconds

mtt.stringifyTime(
	5100300,
	{
		valueNull: true,
		separator: '/'
	}
); // 0y/0mo/0w/0d/1h/25m/0s/3ms

mtt.stringifyTime(
	35071,
	{ suppressTag: true }
); // 35, 71

Convert from string

Here is the list of all the arguments available:

ParameterTypeOptionalDefaultDescription
timestringTime in string to convert into milliseconds
msOffbooleanfalseReturns time in seconds instead of milliseconds

Some usage examples:

mtt.parseTime('1 minute 1 second'); // 61000

mtt.parseTime(
    '2h 5m',
	{ msOff: true }
); // 7500

mtt.parseTime('1 month 2d 4hours'); // 187260000

mtt.stringifyTime(
	35071,
	{ suppressTag: true }
); // 35, 71

Format time

Here is the list of all the arguments available:

ParameterTypeOptionalDefaultDescription
timestringTime to format
formatstringy YYYY, mo MMMM, d DD H:M:S.MSFormat and order of time returned, check here for more information
langstringenLanguage of time unities
longbooleanfalseReturns the whole word (not abbreviations)
suppressTagbooleanfalseReturns time without unities
valueNullbooleanfalseRemoves values equal to zero

Some usage examples:

mtt.formatTime(654686145655); // 20 years, 8 months, 29 days 01:00:25.655

mtt.formatTime(
    65364,
    { format: 'M:S.MS' }
); // 01:05.364

mtt.formatTime(
    449155098,
    { format: 'D DD, h:M:S.ms' }
); // 05 days, 4:45:55.98

Keywords

FAQs

Package last updated on 04 Jun 2022

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc