Function ms

  • Convert a given duration of milliseconds to a string that best represents it.

    If you are very concerned about performance you should use the convertMany function directly.

    Type Parameters

    • Q extends number | bigint

    Parameters

    • quantity: Q

      Duration of milliseconds to convert

    Returns `${_LiteralToPrimitive<Q>}${BestUnitsForMeasure<Time>}`

    A duration string

    Example

    ms(-3 * 60000); // '-3min'
    
  • Convert a duration string to a duration in milliseconds.

    If you are very concerned about performance you should use the convertMany function directly.

    Parameters

    • value: string

      Duration string to convert

    Returns number

    A duration in milliseconds

    Example

    ms('1d 2h 30min'); // 95400000
    

Generated using TypeDoc