Run

Tutorial With Example

Run your live code

 
20
 
1
<!DOCTYPE html>
2
<html lang="en">
3
<head>
4
<meta charset="utf-8">
5
<title>Javascript Setting the Hours, Minutes and Seconds</title>
6
​
7
</head>
8
<body>
9
  <script>
10
    var d = new Date(2022, 7, 15); // Aug 15, 2022 00:00:00
11
    d.setHours(8);
12
    d.setMinutes(30);
13
    d.setSeconds(45);
14
    d.setMilliseconds(600);
15
    document.write(d);
16
  </script>
17
​
18
​
19
</body>
20
</html>