The function for calculating the number of days from a mentioned day to today is as follows:

The input of the function is the date. The date is the format of month/date/year.

 DateDiffrents: function (date) {
                try {
                    if (date != undefined && date != null) {
                        var datearray = date.split('/')
                        if (datearray.length > 1) {
                            var toDate = datearray[2] + "/" + datearray[0] + "/" + datearray[1];
                            var today = new Date();
                            var olddate = new Date(toDate);
                            var timeDifference = Math.abs(today.getTime() - olddate.getTime());
                            var daysDifference = Math.ceil(timeDifference / (1000 * 60 * 60 * 24));
                          
                                return parseInt(daysDifference)


                        }
                    }


                } catch (error) {
                    log.debug('err@errorDateDiffrents', error.message);
                }

            },

Leave a comment

Your email address will not be published. Required fields are marked *