Get started with moment-duration-format CDN

MIT licensed

Moment-duration-format is a JS function that formats duration objects into human-readable strings.

Tags:
  • moment
  • duration
  • format

Stable version

Copied!

How to start using moment-duration-format CDN


// Include the library
const MomentDurationFormat = require('moment-duration-format');
MomentDurationFormat.plugin(require('moment-duration-add'));

// Create a duration object
const duration = Moment.duration(60 * 60 * 1000); // 1 hour

// Format the duration using the library
const formattedDuration = MomentDurationFormat(duration, '{h} hours, {i} minutes');

console.log(formattedDuration.humanize()); // "1 hour"
Copied!
Copied!
Copied!

All versions