简体   繁体   中英

MongoDB UTC DateTime Format To Local Time

I am using MongoDB c# driver to insert data into MongoDB. When I pass DateTime it's automatically storing it in UTC Format. But i want to store that in Local UK time. How to set the field in MongoDB to save in local time format and how to change date that already exists in the MongoDB collection.

MongoDB provides an attribute which automatically does the trick.

[BsonDateTimeOptions(Kind = DateTimeKind.Local)]

might be helpful for someone.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM