Novelty Palliates Malaise

    format-ms
    TypeScript icon, indicating that this package has built-in type declarations

    1.2.1 • Public • Published

    Format Milliseconds

    A utility function for converting milliseconds into a human readable message.

    const { formatMilliseconds, parseMilliseconds } = require('format-ms')
     
    console.log(formatMilliseconds(1000000))
    // output: '16m 40s'
     
    console.log(formatMilliseconds(-445500))
    // output: '7m 25s 500ms ago'
     
    console.log(formatMilliseconds(961000, { units: 'long' }))
    // output: '16 minutes 1 second'
     
    console.log(formatMilliseconds(-445500, { largestOnly: true }))
    // output: '7m ago'
     
    console.log(formatMilliseconds(445500, { ignore: [ 'millisecond' ] }))
    // output: '7m 25s'
     
    console.log(parseMilliseconds(987654321000))
    // output: {
    //   years: 31,
    //   weeks: 21,
    //   days: 0,
    //   hours: 4,
    //   minutes: 25,
    //   seconds: 21,
    //   milliseconds: 0 }

    Install

    npm i format-ms

    DownloadsWeekly Downloads

    5

    Version

    1.2.1

    License

    ISC

    Unpacked Size

    5.08 kB

    Total Files

    4

    Last publish

    Collaborators

    • robb_j