Am working on a functionality where I need to display timestamps stored in mongodb in dd-mm-yyyy
format. But am confused on how to write the query to get the timestamps as in required format.
Below is the sample data of dropdowns collection.
/* 1 */
{
"_id" : ObjectId("5e787e988f3b3f3a240e846e"),
"status" : true,
"company" : ObjectId("5e787e988f3b3f3a240e846d"),
"type" : "ticketstatus",
"name" : "Open",
"createdAt" : ISODate("2020-03-23T09:17:12.374Z"),
"updatedAt" : ISODate("2020-03-23T09:17:12.374Z")
}
/* 2 */
{
"_id" : ObjectId("5e787e988f3b3f3a240e846f"),
"status" : true,
"company" : ObjectId("5e787e988f3b3f3a240e846d"),
"type" : "ticketstatus",
"name" : "Closed",
"createdAt" : ISODate("2020-03-23T09:17:12.374Z"),
"updatedAt" : ISODate("2020-03-23T09:17:12.374Z")
}
/* 3 */
{
"_id" : ObjectId("5e7883ce8f3b3f3a240e8472"),
"status" : true,
"company" : ObjectId("5e787e988f3b3f3a240e846d"),
"type" : "ticketpriorities",
"name" : "High",
"createdAt" : ISODate("2020-03-23T09:39:26.167Z"),
"updatedAt" : ISODate("2020-03-23T09:39:26.167Z")
}
The query am using so far,
dropdowns.find({"company":ObjectId('5e787e988f3b3f3a240e846d')});
What would be the right approach to fetch the dates? Do I need to write a query or do I need to manipulate the returned data from the query using the lines of code? Please suggest me the best and most used way. Thanks.