Below code will return the days left from today to futures date.
Dependencies: jQuery and MomentJs.
var getDaysLeft = function (date) { var today = new Date(); var daysLeftInMilliSec = Math.abs(new Date(moment(today).format('YYYY-MM-DD')) - new Date(date)); var daysLeft = daysLeftInMilliSec / (1000 * 60 * 60 * 24); return daysLeft;};getDaysLeft('YYYY-MM-DD');