-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
26 lines (20 loc) · 974 Bytes
/
script.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
// JavaScript to populate dynamic data
document.addEventListener("DOMContentLoaded", function() {
// Get the current date and time
const now = new Date();
// Get the day of the week
const daysOfWeek = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
const currentDay = daysOfWeek[now.getUTCDay()];
// Update the elements with the dynamic data
document.querySelector('[data-testid="currentDayOfTheWeek"]').textContent = ` ${currentDay}`;
// Initial call to update the UTC time
updateUTCTime();
// Update the UTC time every second (real-time)
setInterval(updateUTCTime, 1000);
});
// Function to update the UTC time in milliseconds
function updateUTCTime() {
const now = new Date();
const currentUTCTimeInMillis = now.getTime(); // Get time in milliseconds
document.querySelector('[data-testid="currentUTCTime"]').textContent = `${currentUTCTimeInMillis}`;
}