1function calculateExamRemainingTime(exam_end_at) {
2
3 $(function(){
4
5 const calcNewYear = setInterval(function(){
6
7 const exam_ending_at = new Date(exam_end_at);
8 const current_time = new Date();
9
10 const totalSeconds = Math.floor((exam_ending_at - (current_time))/1000);;
11 const totalMinutes = Math.floor(totalSeconds/60);
12 const totalHours = Math.floor(totalMinutes/60);
13 const totalDays = Math.floor(totalHours/24);
14
15 const hours = totalHours - ( totalDays * 24 );
16 const minutes = totalMinutes - ( totalDays * 24 * 60 ) - ( hours * 60 );
17 const seconds = totalSeconds - ( totalDays * 24 * 60 * 60 ) - ( hours * 60 * 60 ) - ( minutes * 60 );
18
19 const examRemainingHoursSection = document.querySelector('#remainingHours');
20 const examRemainingMinutesSection = document.querySelector('#remainingMinutes');
21 const examRemainingSecondsSection = document.querySelector('#remainingSeconds');
22
23 examRemainingHoursSection.innerHTML = hours.toString();
24 examRemainingMinutesSection.innerHTML = minutes.toString();
25 examRemainingSecondsSection.innerHTML = seconds.toString();
26
27 },1000);
28 });
29}
30
31calculateExamRemainingTime('2025-06-03 20:20:20');
32