---
title: "unicorn/consistent-date-clone"
description: "Require `new Date(date)` instead of `new Date(date.getTime())` to copy a date"
# Generated by src/codegen/lint-rule-docs.ts. Do not edit below this line.
plugin: "unicorn"
aliases: []
kind: "suggestion"
category: "style"
default: "off"
fixable: "yes"
typeAware: false
deprecated: false
---

The `Date` constructor accepts another `Date` and copies it exactly. Converting it to a number first with `.getTime()` adds a call and gives the same result.

`--fix` removes the `.getTime()` call.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. To turn it on:

```toml bunfig.toml
[lint.rules]
"unicorn/consistent-date-clone" = "error" # or "warn"
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad */}
```js
const deadline = new Date(start.getTime());
deadline.setDate(deadline.getDate() + 7);
```

Not reported:

{/* good */}
```js
const deadline = new Date(start);
deadline.setDate(deadline.getDate() + 7);
```

Arithmetic on the timestamp isn't a plain copy, so it's allowed:

{/* good */}
```js
const deadline = new Date(start.getTime() + 60_000);
```
