Adding get-days-difference-between-dates
This commit is contained in:
13
README.md
13
README.md
@ -36,6 +36,7 @@
|
||||
* [Fibonacci array generator](#fibonacci-array-generator)
|
||||
* [Filter out non unique values in an array](#filter-out-non-unique-values-in-an-array)
|
||||
* [Flatten array](#flatten-array)
|
||||
* [Get days difference between dates](#get-days-difference-between-dates)
|
||||
* [Get max value from array](#get-max-value-from-array)
|
||||
* [Get min value from array](#get-min-value-from-array)
|
||||
* [Get native type of value](#get-native-type-of-value)
|
||||
@ -66,7 +67,7 @@
|
||||
* [Promisify](#promisify)
|
||||
* [Random integer in range](#random-integer-in-range)
|
||||
* [Random number in range](#random-number-in-range)
|
||||
* [Redirect to URL](#redirect-to-url)
|
||||
* [Redirect to url](#redirect-to-url)
|
||||
* [Reverse a string](#reverse-a-string)
|
||||
* [RGB to hexadecimal](#rgb-to-hexadecimal)
|
||||
* [Run promises in series](#run-promises-in-series)
|
||||
@ -412,6 +413,16 @@ const flatten = arr => arr.reduce((a, v) => a.concat(v), []);
|
||||
// flatten([1,[2],3,4]) -> [1,2,3,4]
|
||||
```
|
||||
|
||||
[⬆ back to top](#table-of-contents)
|
||||
### Get Days Difference Between Dates
|
||||
|
||||
Returns the number of days between two Dates.
|
||||
|
||||
```js
|
||||
const getDaysDiffBetweenDates = (dateInitial, dateFinal) => (dateFinal - dateInitial) / (1000 * 3600 * 24);
|
||||
//getDaysDiffBetweenDates(new Date("2017-12-13"), new Date("2017-12-22")) -> 9
|
||||
```
|
||||
|
||||
[⬆ back to top](#table-of-contents)
|
||||
### Get max value from array
|
||||
|
||||
|
||||
8
snippets/get-days-difference-between-dates.md
Normal file
8
snippets/get-days-difference-between-dates.md
Normal file
@ -0,0 +1,8 @@
|
||||
### Get Days Difference Between Dates
|
||||
|
||||
Returns the number of days between two Dates.
|
||||
|
||||
```js
|
||||
const getDaysDiffBetweenDates = (dateInitial, dateFinal) => (dateFinal - dateInitial) / (1000 * 3600 * 24);
|
||||
//getDaysDiffBetweenDates(new Date("2017-12-13"), new Date("2017-12-22")) -> 9
|
||||
```
|
||||
Reference in New Issue
Block a user