Set MongoDB GMT Time in C#

6/7/2014
Responsive image
Photo by Ben on Unsplash

Save DateTime as GMT time to mongo DB

You can set the UTC Date in property level and set when insert.

Property Attribute to save time as UTC

[BsonDateTimeOptions(Kind = DateTimeKind.Utc)] public DateTime UpdateDate { get; set; }

Save Date when Insert to MongoDatabase.

table.CreateDate = DateTime.UtcNow;

 

Reference about GMT

http://www.nationalgeographic.com/geobee/study-corner/activity-10/