Skip to content

Commit 902a7de

Browse files
committed
Add comments and fix code
1 parent a7571a1 commit 902a7de

File tree

2 files changed

+216
-193
lines changed

2 files changed

+216
-193
lines changed

datetime-jsp/datetime.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ var second = document.querySelector("#second");
77
function setCurrentDate() {
88
var currentDate = new Date();
99
var currentYear = currentDate.getFullYear();
10-
var currentMonth = currentDate.getMonth() + 1;
10+
var currentMonth = currentDate.getMonth() + 1;//Add 1 to month because 0 is January in JavaScript and 1 in Java
1111
var currentDay = currentDate.getDate();
1212
var currentHour = currentDate.getHours();
1313
var currentMinute = currentDate.getMinutes();
1414
var currentSecond = currentDate.getSeconds();
15-
year.value = currentYear;
15+
year.value = currentYear;//set the input values to current local date and time
1616
month.value = currentMonth;
1717
day.value = currentDay;
1818
hour.value = currentHour;
@@ -27,7 +27,7 @@ function setCurrentUtcDate() {
2727
var currentUtcHour = currentDate.getUTCHours();
2828
var currentUtcMinute = currentDate.getUTCMinutes();
2929
var currentUtcSecond = currentDate.getUTCSeconds();
30-
year.value = currentUtcYear;
30+
year.value = currentUtcYear;//set the input values to current UTC date and time
3131
month.value = currentUtcMonth;
3232
day.value = currentUtcDay;
3333
hour.value = currentUtcHour;

0 commit comments

Comments
 (0)