I have a api which needs to store a utc+timestamp in mongodb. I am trying to save the value in mongodb which is saving in UTC time. While retreiving i am trying to send the current time using the below code
The above code is working fine. Now i have a use case as the input format will be
I need to get the timeZone from the offset above likeif i pass +0900 i need output as "Asia/Seoul",Any idea as how can I proceed forward? Kindly help
2022-02-04T08:19:38Z+09:00 is not valid.
Z indicates UTC time while
+09:00 indicates UTC offest, i.e. you provide a timestamp with two (different) time zones.
As it is ambiguous I cannot propose a solution. Is
2022-02-04T08:19:38 intended to be UTC or Seoul time?
This one would work:
MongoDB stores date values as UTC time - always and only! If you need to preserver the input time zone, then you have to store it separately in an extra field.