• 코드:
​x
 
1
<!DOCTYPE html>
2
<html lang="ko">
3
​
4
<head>
5
    <meta charset="UTF-8">
6
    <title>JavaScript Date Object</title>
7
</head>
8
​
9
<body>
10
​
11
    <h1>현재 날짜와 시간으로 Date 객체 생성</h1>
12
​
13
    <p>결과보기를 다시 누를 때마다 현재 시간이 갱신됩니다.</p>
14
    <script>
15
        var date = new Date();  // Date 객체 생성
16
        document.write(date);
17
    </script>
18
    
19
</body>
20
​
21
</html>