0
 $(document).ready(function () {
    var bc;

    $('#kullaniciTableBody tr').each(function () {
        bc = $("#kullaniciTableBody td.lastday").attr("data-lastday");
    });

    lastDay = new Date(bc);
    nowDate = new Date();
    daysLeft = new Date(lastDay - nowDate);

    result = Math.floor(daysLeft / 1000 / 60 / 60 / 24);

    $(this).find(".lastday").text(result);
});

Hello! I want to subtract today's date from the date field on my table and get the remaining number of days.

Aziza Kasenova
  • 1,501
  • 2
  • 10
  • 22
  • Will this help https://stackoverflow.com/questions/2627473/how-to-calculate-the-number-of-days-between-two-dates ? – Kiran Feb 07 '21 at 18:11

1 Answers1

0

const startDate = new Date("06/30/2019");
const endDate = new Date("07/30/2019");

const differenceInTime = endDate.getTime() - startDate.getTime();
const differenceInDays = differenceInTime / (1000 * 3600 * 24);

console.log(differenceInDays);
Aziza Kasenova
  • 1,501
  • 2
  • 10
  • 22
Li Xing
  • 111
  • 3
  • 12