Last Updated : Jan 1, 2023
First way is to print date with full numbers only and other method is you can print date with text as long date.
As, there are many methods with the help of which we can print current date.
- First, we write <! DOCTYPE html> which we used as an instruction to the web browser about what version of HTML file is written in.
- Secondly, the <html> tag is used to indicate the beginning of an HTML document.
- As above now <head> tag is used to contain information about web page. In this tag a <title> tag is used which helps us to specify a webpage title. Both <head> and <title> tags are Paired tags. So, both have </head> and </title> ending tags respectively.
- Here, then we create a body tag. All the content which we want to show on browser’s screen or display is always written inside this codes.
- Here, we write some code to print current date inside body. First of all we create two headings after then the main code starts. Here, we create a paragraph tag in which we print current date and then a button on click a function runs and date gets printed.
- And here, we create a function which runs on button click. Inside this function, we store current date into a variable name as date with the help of inbuilt function that is Date() and convert it into string also.
- So, the date printed in format, for example like: Sun Nov 7 2077.
- At last, the <body> and <html> tags are closed with </body> and </html> respectively.