
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Convert ISODate to Numerical Value in MongoDB
You can use getTime() for this. Following is the syntax −
yourVariableName.getTime();
Convert ISODate to numerical value −
> var arrivalDate=ISODate('2019-04-18 13:50:45');
Following is the query to convert ISODate to numerical value −
> arrivalDate.getTime();
This will produce the following output −
1555595445000
Let us verify that it is a correct numerical value for ISODate or not. Following is the query to get correct ISODate whenever we apply above numeric value −
> new Date(1555595445000);
This will produce the following output −
ISODate("2019-04-18T13:50:45Z")
Yes, this is a correct ISODate.
Advertisements