Skip to main content

utils.prettymilliseconds

Home > @nipem/utils > prettyMilliseconds

prettyMilliseconds() function

将毫秒格式化成 n天n小时n分钟n秒[n毫秒]

Signature:
export declare function prettyMilliseconds(milliseconds: number, keepMilliseconds?: boolean): string;

Parameters

ParameterTypeDescription
millisecondsnumber需要被格式化的时间,单位毫秒
keepMillisecondsboolean(Optional) 是否保留毫秒,默认保留
Returns:

string

格式化后的时间字符串

Example

// 默认保留毫秒
prettyMilliseconds(1337000001) // 15天11小时23分钟20秒1毫秒

// 不保留毫秒
prettyMilliseconds(1337000001, false) // 15天11小时23分钟20秒