I want to convert existing field of type string having date like "Fri Jun 10 14:05:28 IST 2022"to date type ISO (utc).
i tried $convert , but it is converting it utc by only reducing time by 2 hours, while it should be reducing it by 5 and a half hours when converting IST to utc
Sample document
[
{
"_id": {
"$oid": "62a30251c8503f782b572e0c"
},
"start_time": "Fri Jun 10 14:05:28 IST 2022",
"stop_time": "undefined",
}
]
MongoServerError: PlanExecutor error during aggregation :: caused by :: you cannot pass in a date/time string with time zone information (‘IST’) together with a timezone argument
So it would seems like $dateFromString correctly infers IST as the timezone to use.
Replacing IST in the source string using the alternative way to specify the timezone works. The following string works without specifying the timezone in $dateFromString:
'Fri Jun 10 14:05:28 -0530 2022'
Alternatively the string 'Fri Jun 10 14:05:28 2022' also works when specifying “-0530” in $dateFromString.