- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to format JavaScript date into yyyy-mm-dd format?
To format a JavaScript date into “yyyy-mm-dd” format, use the toISOString() method. It converts using ISO standard i.e.
YYYY-MM-DDTHH:mm:ss.sss
Example
You can try to run the following code to format a date.
<html> <head> <title>JavaScript Dates</title> </head> <body> <script> var date, res; date = new Date(); res = date.toISOString(); document.write(res); </script> </body> </html>
Output
2018-12-15T08:13:47.648Z
Advertisements