javascript get number of days between two dates
function dateDiffInDays(date1, date2) {
// round to the nearest whole number
return Math.round((date2-date1)/(1000*60*60*24));
}
var daysDiff=dateDiffInDays(new Date('December 21, 2019 03:24:00'), new Date('December 25, 2019 03:24:00')); //4 days till XMASconst diffDays = (date, otherDate) => Math.ceil(Math.abs(date - otherDate) / (1000 * 60 * 60 * 24));
// Example
diffDays(new Date('2014-12-19'), new Date('2020-01-01')); // 1839
Also in JavaScript:
- banking program deposit and withdrawal using ajax call
- react-native-screens
- find year javascript
- javascript regex only letters and spaces
- responsive calc height react native
- how to add multiple event listener in javascript
- css and js on flask
- how to install all needed modules in node
- javascript array remove element
- bs modal service close
- javascript whitespace strip
- readonly attribute in html by javascript
- function redirect javascript
- how to get the first character of a string in javascript
- count number of each element in array javascript
- how to query chain an id in an id javascript
- how to integrate vuejs with nodejs and express
- remove disabled attribute javascript
- using laravel variable inside alpine js
- javascript deap clone an object
- array in js
- capacitor.ionicframework.com to apk
- javascript set variable if not defined
- react generate ethereum address