Skip to content

Function: clone()

ts
function clone(date): Date;

Return a copy of a date (new Date with the same time value). 返回日期的副本(相同时间戳的新 Date)。

Parameters

ParameterType
dateDate

Returns

Date

Example

ts
const d = new Date('2026-05-08T12:00:00')
const c = clone(d)
c.getTime() === d.getTime() // => true
c === d // => false

Since

1.0.0

Released under the MIT License.