
function calculateDaysDifference(targetDateString) {
const currentDate = new Date();
const targetDate = new Date(targetDateString);
const timeDifference = targetDate - currentDate;
const daysDifference = Math.max(Math.floor(timeDifference / (1000 * 60 * 60 * 24)), 0);
const hoursDifference = Math.max(Math.floor((timeDifference % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)), 0);
const minutesDifference = Math.max(Math.floor((timeDifference % (1000 * 60 * 60)) / (1000 * 60)), 0);
return {
days: daysDifference,
hours: hoursDifference,
minutes: minutesDifference
};
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23