Adding get-days-difference-between-dates

This commit is contained in:
Leandro Franciscato
2017-12-14 10:36:36 -02:00
parent 54dc5e9e39
commit c54c4db018
2 changed files with 20 additions and 1 deletions

View File

@ -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

View 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
```