Reputation: 31
My Date is in the format 2020-07-08 00:00:00 Asia/Kolkata
I tried, with ISODate function, which takes DateFormat and Timezone, but it created the date 5 H 30 M ahead of this time, which should be 3 H 30 M ahead. As Tokyo time is 3 H 30 M ahead of India time.
Upvotes: 0
Views: 435
Reputation: 3349
You can use $dateFromParts
to manipulate ISODate
to any required format.
Check if the below query helps you out
db.test4.aggregate([
{$project:{
"original": "$date",
"convertedDate": {
'$dateFromParts': {
'year': {$year:{date:'$date'}},
'month': {$month:{date:'$date'}},
'day': {$dayOfMonth:{date:'$date'}},
'hour': {$hour:{date:'$date'}},
'minute': {$minute:{date:'$date'}},
'second': {$second:{date:'$date'}},
'millisecond': {$millisecond:{date:'$date'}},
'timezone': '-0330',
}
}
}}
])
Upvotes: 1