File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change 1+ <!--
2+
3+ Write a JavaScript program to get the current date.
4+
5+ -->
6+
7+ <!DOCTYPE html>
8+ < html lang ="en ">
9+ < head >
10+ < meta charset ="UTF-8 ">
11+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge ">
12+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
13+ < title > Current Date</ title >
14+ </ head >
15+
16+ < body > </ body >
17+
18+ < script >
19+
20+ let today = new Date ( ) ;
21+ let dd = today . getDate ( ) ;
22+
23+ let mm = today . getMonth ( ) + 1 ;
24+ const yyyy = today . getFullYear ( ) ;
25+ if ( dd < 10 ) {
26+ dd = `0${ dd } ` ;
27+ }
28+
29+ if ( mm < 10 ) {
30+ mm = `0${ mm } ` ;
31+ }
32+
33+ today = `${ mm } -${ dd } -${ yyyy } ` ;
34+ console . log ( today ) ;
35+
36+ today = `${ mm } /${ dd } /${ yyyy } ` ;
37+ console . log ( today ) ;
38+
39+ today = `${ dd } -${ mm } -${ yyyy } ` ;
40+ console . log ( today ) ;
41+
42+ today = `${ dd } /${ mm } /${ yyyy } ` ;
43+ console . log ( today ) ;
44+
45+ </ script >
46+
47+ </ html >
You can’t perform that action at this time.
0 commit comments