
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
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
- Related Questions & Answers
- PHP program to change date format
- Format date value in MongoDB shell?
- PHP program to change the date format
- How to change date time format in HTML5?
- Change the curdate() (current date) format in MySQL
- How to change date format with DATE_FORMAT() in MySQL?
- How to change date and time format in Android sqlite?
- Best way to change the date format in MySQL SELECT?
- Change date format in MySQL database table to d/m/y
- Is there a way to change the date format in php?
- MongoDB query to fetch date records (ISODate format) in a range
- How to filter a query on specific date format with MongoDB?
- Unix date format in Java
- Change date format (in DB or output) to dd/mm/yyyy in PHP MySQL?
- Convert MySQL Unix-Timestamp format to date format?
Advertisements