File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
Expand file tree Collapse file tree 2 files changed +22
-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 > Document</ title >
7+ </ head >
8+ < body >
9+ < input type ="date " />
10+
11+ < script src ="script.js "> </ script >
12+ </ body >
13+ </ html >
Original file line number Diff line number Diff line change 1+ document . addEventListener ( "DOMContentLoaded" , ( event ) => {
2+ const dateInput = document . querySelector ( "input" ) ;
3+ const today = new Date ( ) ;
4+ const year = today . getFullYear ( ) ;
5+ const month = String ( today . getMonth ( ) + 1 ) . padStart ( 2 , "0" ) ; // Months are zero-based
6+ const day = String ( today . getDate ( ) ) . padStart ( 2 , "0" ) ;
7+ const formattedDate = `${ year } -${ month } -${ day } ` ;
8+ dateInput . value = formattedDate ;
9+ } ) ;
You can’t perform that action at this time.
0 commit comments