Commit 51323d8 1 parent c2282b0 commit 51323d8 Copy full SHA for 51323d8
File tree 1 file changed +48
-0
lines changed
1 file changed +48
-0
lines changed 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
+ < title > Countdown Timer</ title >
7
+ < style >
8
+ body {
9
+ display : flex;
10
+ justify-content : center;
11
+ align-items : center;
12
+ height : 100vh ;
13
+ font-family : Arial, sans-serif;
14
+ }
15
+ # countdown {
16
+ font-size : 48px ;
17
+ }
18
+ </ style >
19
+ </ head >
20
+ < body >
21
+ < div id ="countdown "> 10:00</ div >
22
+ < script >
23
+ // Set the date we're counting down to
24
+ var countDownDate = new Date ( ) . getTime ( ) + 10 * 60 * 1000 ; // 10 minutes from now
1
25
26
+ // Update the count down every 1 second
27
+ var x = setInterval ( function ( ) {
28
+ // Get today's date and time
29
+ var now = new Date ( ) . getTime ( ) ;
30
+
31
+ // Find the distance between now and the count down date
32
+ var distance = countDownDate - now ;
33
+
34
+ // Time calculations for minutes and seconds
35
+ var minutes = Math . floor ( ( distance % ( 1000 * 60 * 60 ) ) / ( 1000 * 60 ) ) ;
36
+ var seconds = Math . floor ( ( distance % ( 1000 * 60 ) ) / 1000 ) ;
37
+
38
+ // Display the result in the element with id="countdown"
39
+ document . getElementById ( "countdown" ) . innerHTML = minutes + ":" + ( seconds < 10 ? "0" : "" ) + seconds ;
40
+
41
+ // If the count down is finished, write some text
42
+ if ( distance < 0 ) {
43
+ clearInterval ( x ) ;
44
+ document . getElementById ( "countdown" ) . innerHTML = "TIME'S UP!" ;
45
+ }
46
+ } , 1000 ) ;
47
+ </ script >
48
+ </ body >
49
+ </ html >
You can’t perform that action at this time.
0 commit comments