-
Notifications
You must be signed in to change notification settings - Fork 7
/
25-dateObject.html
40 lines (31 loc) · 1.3 KB
/
25-dateObject.html
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
36
37
38
39
40
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Demo</title>
</head>
<body>
<script type="text/javascript">
// Working with date objects
/*
Let's make a JavaScript clock
*/
var fullDate = new Date();
var printTime = function() {
var nowTime = new Date();
var date = nowTime.getDate();
var month = nowTime.getMonth() + 1; // Because there is not a calendar anywhere that goes from 0 - 11?
var fullYear = nowTime.getFullYear();
var hours = nowTime.getHours();
var minutes = nowTime.getMinutes();
var seconds = nowTime.getSeconds() + 1; // Because there is not a clock anywhere that goes from 0 - 59?
document.write(month + ' / ' + date + ' / ' + fullYear + ' ' + hours + ' : ' + minutes + ' : ' + seconds + '<br>');
}
//document.write(fullDate + '<br>');
setInterval('printTime()', 1000);
// All the date object methods
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
</script>
</body>
</html>