How to format a JavaScript date?
Answers
Answered by
2
JavaScript Date Time
You can get the current date and time in JavaScript using the Date object.
// the following gives the current date and time object
new Date()
Copy
Using the date object you can print the current date and time.
let current_datetime = new Date()
console.log(current_datetime.toString())
Copy
The above code outputs the current date and time as shown:
// output
"Fri Oct 19 2018 17:10:12 GMT+0530 (IST)"
Copy
JavaScript Date Time Format
The above shown date time is the default format. It’s not so straight to change JavaScript date time format.
Similar questions