Timestamp for Cosmosdb with mongodb API

MikeZheng-3371 46 Reputation points
2022-06-07T18:05:58.307+00:00

What is the best practice to generate a local timestamp on cosmosDB with mongoDB api? The more accurate the better. What data type / format should be stored in the cosmosDB, how do we handle the different timezone, and etc.

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,902 questions
{count} votes

1 answer

Sort by: Most helpful
  1. GeethaThatipatri-MSFT 29,542 Reputation points Microsoft Employee Moderator
    2022-06-08T09:39:17.993+00:00

    Hi, @MikeZheng-3371 Thanks for the question and for using the MS Q&A platform.
    You can use $currentDate here you can find the documentation. Cosmos DB API for MongoDB will follow the same format for date and timestamp fields as MongoDB, and the time will be in UTC, as there is no timezone concept.
    Click here for reference doc

    Please let me know if you need any additional information.

    Regards
    Geetha


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.