removed daysBetween.md

This commit is contained in:
nonseodion
2020-10-09 10:12:09 +01:00
committed by GitHub
parent 2431ddc820
commit c52a748de0

View File

@ -1,18 +0,0 @@
---
title: daysBetween.md
tags: date,begineer
---
Returns the number of days between two `Date` objects.
- Subtract the two `Date` objects and find the absolute value using `Math.abs()`
- Divide by the number of milliseconds in a day
```js
const daysBetween = (date1, date2) =>
Math.abs(date1 - date2) / (1000 * 60 * 60 * 24)
```
```js
daysBetween(new Date("11-1-2020"), new Date("11-3-2020")); // 2
```