File tree Expand file tree Collapse file tree 5 files changed +69
-0
lines changed Expand file tree Collapse file tree 5 files changed +69
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Digital Clock
2
+
3
+ This is a simple digital clock written using HTML, CSS and JS.
4
+
5
+ ## How to Run?
6
+
7
+ Double Click on index.html and you will be good to go.
8
+
9
+ ## Screenshot
10
+
11
+ ![ image] ( images/Digital-Clock.png )
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+ < head >
4
+ < meta charset ="UTF-8 ">
5
+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6
+ < link rel ="stylesheet " href ="style.css ">
7
+ < title > Digital Clock</ title >
8
+ </ head >
9
+ < body >
10
+ < div id ="digitalClock ">
11
+
12
+ </ div >
13
+ < script src ="index.js "> </ script >
14
+ </ body >
15
+ </ html >
Original file line number Diff line number Diff line change
1
+ function clock ( ) {
2
+ // Getting Time
3
+ let now = new Date ( )
4
+ let hours = now . getHours ( )
5
+ let min = now . getMinutes ( )
6
+ let seconds = now . getSeconds ( )
7
+ hours = ( hours < 10 ) ? `0${ hours } ` : hours
8
+ min = ( min < 10 ) ? `0${ min } ` : min
9
+ seconds = ( seconds < 10 ) ? `0${ seconds } ` : seconds
10
+ if ( hours > 12 ) {
11
+ document . getElementById ( 'digitalClock' ) . innerHTML = `${ hours % 12 } :${ min } :${ seconds } PM`
12
+ }
13
+ else
14
+ document . getElementById ( 'digitalClock' ) . innerHTML = `${ hours } :${ min } :${ seconds } AM`
15
+ }
16
+ setInterval ( clock , 1000 )
Original file line number Diff line number Diff line change
1
+ * {
2
+ margin : 0 ;
3
+ padding : 0 ;
4
+ box-sizing : border-box;
5
+ }
6
+
7
+ body , html {
8
+ height : 100% ;
9
+ width : 100% ;
10
+ margin : 0 ;
11
+ padding : 0 ;
12
+ background : # 1661ee ;
13
+ font-family : Lato, arial;
14
+ }
15
+
16
+ # digitalClock {
17
+ position : absolute;
18
+ top : 50% ;
19
+ left : 50% ;
20
+ transform : translate (-50% , -50% );
21
+ -ms-transform : translate (-50% , -50% );
22
+ -webkit-transform : translate (-50% , -50% );
23
+ height : max-content;
24
+ margin : auto;
25
+ font-size : 7vw ;
26
+ color : white;
27
+ }
You can’t perform that action at this time.
0 commit comments