convertTime

Type:Function
Status:stable
Since:1.0.0
Platform:jsnode
@blackbyte.sugar.shared.datetime

This function allows you to convert time like seconds, ms, hours, minutes, etc… from one format to another

Params

  1. from*-String|Number

    The value to start from like ”10s”, “20ms”, “2h”, etc… Supports ‘ms’, ‘millisecond’, ‘milliseconds’, ‘s’, ‘second’, ‘seconds’, ‘m’, ‘minute’, ‘minutes’, ‘h’, ‘hour’, ‘hours’, ‘d’, ‘day’, ‘days’, ‘w’, ‘week’, ‘weeks’, ‘month’, ‘months’, ‘y’, ‘year’, ‘years’

  2. to“‘ms‘“String

    The format you want to get back. Can be ‘ms’ | ‘millisecond’ | ‘milliseconds’ | ‘s’ | ‘second’ | ‘seconds’ | ‘m’ | ‘minute’ | ‘minutes’ | ‘h’ | ‘hour’ | ‘hours’ | ‘d’ | ‘day’ | ‘days’ | ‘w’ | ‘week’ | ‘weeks’ | ‘month’ | ‘months’ | ‘y’ | ‘year’ | ‘years’

Return

  1. -Number

    The converted value

Example

import { convertTime } from '@blackbyte/sugar/datetime';
convertTime('10s', 'ms'); // => 10000

Todo

  • testsnormal