mongodbspring-mongodb

How to store date in IST format in MongoDb


Unable to store date in IST format in mongo DB

Currently storing date in UTC format during every operations i have to change it into IST format using timezone feature provided by mongo


Solution

  • You can not do that. MongoDB will always save time in UTC.

    MongoDB stores times in UTC by default, and converts any local time representations into this form. Applications that must operate or report on some unmodified local time value may store the time zone alongside the UTC timestamp, and compute the original local time in their application logic.

    You can check the official docs for more info.