-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (27 loc) · 1.23 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var arrivalDay = new Date("June 30, 2019 16:30:00");
function calculateTimeToArrival() {
var now = new Date();
var diff = arrivalDay - now;
var realTime = diff / 86400000;
var days = realTime.toString().split('.')[0];
var hourDecimal = realTime.toString().split('.')[1];
var convertHourDemical = `0.${hourDecimal}`;
var fractionHourRemaining = parseFloat(convertHourDemical) * 24;
var hours = fractionHourRemaining.toString().split('.')[0];
var minuteDecimal = fractionHourRemaining.toString().split('.')[1];
var convertMinuteDecimal = `0.${minuteDecimal}`;
var fractionMinuteRemaining = parseFloat(convertMinuteDecimal) * 60;
var minutes = fractionMinuteRemaining.toString().split('.')[0];
var secondDecimal = fractionMinuteRemaining.toString().split('.')[1];
var convertSecondDecimal = `0.${secondDecimal}`;
var fractionSecondRemaining = parseFloat(convertSecondDecimal) * 60;
var seconds = fractionSecondRemaining.toString().split('.')[0];
updateTimeToArrival(days, hours, minutes, seconds);
}
function updateTimeToArrival(days, hours, minutes, seconds) {
$('.days').text(days);
$('.hours').text(hours);
$('.minutes').text(minutes);
$('.seconds').text(seconds);
}
setInterval(calculateTimeToArrival, 100);