Last Updated : Jul 1, 2023
There are multiple techniques for obtaining a date in various formats and doing time zone conversions. The functions that print the Date and time in Coordinated Universal Time (UTC), and it is the global standard time set by the World Time Standard.
Let's have a look at the Date () method by default:
<!DOCTYPE html> <html> <head> <title></title> </head> <body> <script> const date = new Date(2022, 9, 14, 9, 14); console.log(date.toString()); // OR console.log(date); </script> </body> </html>
- To begin, type <! DOCTYPE html> to tell the web browser that the file is in HTML format.
- The <html> element, on the other hand, is used to signal the start of HTML content.
- The <head> tag now contains the information about web pages. The < title> element is used in this tag to provide a web page title. For example, the < head> and < title> tags are paired tags. As a result, both have the </head> and </title> closing tags.
- Simply pass a language, and a country as parameters to the function (in standard locale code format, i.e. 'en-US'), and the Date library will format the output to the specified locale:
- Finally < body> and <html> tags are closed with< /body> and </html>, respectively.
If you require a more complicated data format, you'll have to design one yourself.