 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Change date format in MongoDB
We have the following date −
01-10-2019
To change the date format, let us use custom variable and convert date to a string and change its format −
Following is the query to implement date to string −
> var inputDate="01-10-2019"; > var formatDate= inputDate.split(/-|\//); > var outputString= formatDate[2]+'-'+formatDate[0]+'-'+formatDate[1];
Displaying the variable value −
> print(outputString);
This will produce the following output −
2019-01-10
Advertisements
 