Timezone Conversion from one to another

I have a collection called ProductPrice which contains ProductCode, ProductPrice,CreatedDateTime and CreatedTimeZone along with other fields. When user retrieve this data I want to display ProductCode, ProductPrice, CreatedDateTime, CreatedTimeZone, UTCconvertedDateTime.

Please help me convert the CreatedDateTime column into UTCDateTime using CreatedTimeZone column.

Hey :wave: @Niju_Jose,

Welcome to the MongoDB Community forums :sparkles:

The ISODate in MongoDB is already in UTC. If I insert a new document in MongoDB Collection, it will get saved in UTC only.

{
  "_id": {
    "$oid": "64142cfe6abcfbb8b232d1a1"
  },
  "date": {
    "$date": "2023-03-17T09:03:37.567Z"
  }
}

To understand the question better, please provide further details, such as:

  • The sample document from your MongoDB dataset.
  • How the CreatedTimeZone and CreatedDateTime is being created in this context.
  • The MongoDB Version you are using.
  • The expected result documents.
  • Any queries that you have tried to achieve the required results?

Best,
Kushagra

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.