Converting isodate to numerical value in MongoDB?

MongoDBDatabaseBig Data Analytics

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.

raja
Published on 30-Apr-2019 09:05:24
Advertisements