Get date diff in days between two dates

Here is the code

function daysBetween(startDate, endDate) {
    var millisecondsPerDay = 1000 * 60 * 60 * 24;
    var startDateUTC = Date.UTC(startDate.getFullYear(), startDate.getMonth(), startDate.getDate());
    var endDateUTC = Date.UTC(endDate.getFullYear(), endDate.getMonth(), endDate.getDate());
    return Math.floor((endDateUTC - startDateUTC) / millisecondsPerDay);

Related Post

Latest Post

Recent Posts Widget

Make sure to never miss a thing...

Get the latest news from the creative industry along with other creative goodies, conveniently delivered to social media.