Set MongoDB GMT Time in C#

2014/6/71 min read
bookmark this
Responsive image

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/