-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
20 lines (17 loc) · 849 Bytes
/
script.js
File metadata and controls
20 lines (17 loc) · 849 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// getting html element with document object
const txtDate=document.getElementById("date");
const txtDay=document.getElementById("day");
const txtMonth=document.getElementById("month");
const txtYear=document.getElementById("year");
// retriving data using Date Object
const fetchDate=()=>{
let currentDate=new Date();
const weekDays=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]
const months=["January","Feburary","March","April","May","June","July","August","September","October","November","December"]
txtDate.innerHTML=(currentDate.getDate()<10?"0":"")+currentDate.getDate();
txtDay.innerHTML=(currentDate.getDay<10?"0":"")+weekDays[currentDate.getDay()]
txtMonth.innerHTML=months[currentDate.getMonth()];
txtYear.innerHTML=currentDate.getFullYear();
}
// invoking function
fetchDate();