-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlab8.js
More file actions
25 lines (22 loc) · 879 Bytes
/
lab8.js
File metadata and controls
25 lines (22 loc) · 879 Bytes
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
function showDate(params) {
let out = document.getElementById('today');
let today = new Date();
out.innerHTML = 'Сегодня: ' + today.toLocaleDateString ('ru-RU');
}
function showDaysCount(params){
let today = new Date();
let inputDate = document.querySelector('input[type=date]');
let birthday = new Date(inputDate.value);
let daysCount = (today - birthday)/1000/60/60/24;
let result = document.getElementById('result');
daysCount = Math.ceil (daysCount);
result.innerHTML = 'С даты рождения прошло дней:' + daysCount;
}
window.addEventListener('load', showDate);
function showTime() {
let outTime = document.getElementById('time');
let currentTime = new Date();
outTime.innerHTML = currentTime.toLocaleTimeString('ru');
}
window.addEventListener('load', showTime);
setInterval(showTime, 1000);