date difference
$datetime1 = new DateTime('2020-10-11 16:52:52');
$datetime2 = new DateTime('2020-10-13 16:52:52');
$interval = $datetime1->diff($datetime2);
echo $interval->format('%a days');function daysBetween(first, second) {
// Copy date parts of the timestamps, discarding the time parts.
var one = new Date(first.getFullYear(), first.getMonth(), first.getDate());
var two = new Date(second.getFullYear(), second.getMonth(), second.getDate());
// Do the math.
var millisecondsPerDay = 1000 * 60 * 60 * 24;
var millisBetween = two.getTime() - one.getTime();
var days = millisBetween / millisecondsPerDay;
// Round down.
return Math.floor(days);
// it will return date difference in days
}
Also in JavaScript:
- get start of day javascript
- how to use await to console
- js get base url
- Amazon VPC supporting 5 different IP address ranges and i wanted to know how wide those rangers are
- javascript print int with leading zeros
- host angular app on node server
- inverser l'ordre des item d'un array js
- get last item in array javascript
- select a form by name jquery
- React hooks update parent state from child
- vs code terminal json object not showing something shows [object]
- ngmodel div angular 7
- jquery get the parent node
- RFC8259 json
- Converting circular structure to JSON
- array in javascript
- remove axis tick ends d3
- binary to ascii javascript
- useref react
- js array find
- heroku router Cannot GET
- next js create store
- react how to create range
- node js store add values in file