Skip to content

Function: timeTo()

ts
function timeTo(date, options?): string;

Relative time from now to a future date — e.g., "in 3 days" / "3 天后". 与现在的相对时间(面向未来),如 "3 天后"。

Parameters

ParameterType
dateDate
optionsstring | RelativeOptions

Returns

string

Example

ts
timeTo(new Date(Date.now() + 86400000 * 3)) // 'in 3 days' or '3 天后'

Since

1.0.0

Released under the MIT License.