0

Change Divi blog module date format first :  m/d/Y

var fullDate = new Date();
var twoDigitMonth = ((fullDate.getMonth().length+1) === 1)? (fullDate.getMonth()+1) :(fullDate.getMonth()+1);
var currentDate = twoDigitMonth + "/" + fullDate.getDate() + "/" + fullDate.getFullYear();
 function daysdifference(firstDate, secondDate){
    var startDay = new Date(firstDate);
    var endDay = new Date(secondDate);
        var millisBetween = startDay.getTime() - endDay.getTime();
    var days = millisBetween / (1000 * 3600 * 24);
        return Math.round(Math.abs(days));
}
 jQuery('.blog_two_col article .published').each(function(){
    var post_date = jQuery(this).text();
    jQuery(this).attr('data-date', post_date);
    var days = daysdifference(post_date, currentDate);
    jQuery(this).html(days+' days ago');
});

Jagdish Sarma Asked question May 7, 2021
Add a Comment