shared
utils
string
object
is
extension
js
tracking
string
dom
when
selection
position
iframe
event
scroll
console
node
string
project
fs
console
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
- 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’
- 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
- -Number
The converted value
Example
import { convertTime } from '@blackbyte/sugar/datetime';
convertTime('10s', 'ms'); // => 10000Todo
- testsnormal
Author
- Olivier Bosselolivier.bossel@gmail.comhttps://blackbyte.space