Convert MongoDB BsonTimestamp to C# DateTime

MongoDB’s Timestamp is the elapsed seconds since the Unix epoch (1970/1/1). Therefore, the conversion from Timestamp to DateTime with using C# and .NET MongoDB Driver 2.0 is like this:

DateTime datetime = new DateTime(1970, 1, 1).AddSeconds(bsonTimestamp.Timestamp);

Timestamp Format

According to the MongoDB Manual 3.0, the first integer value is the elapsed seconds since the Unix epoch. The second one is an ordinal number to make the Timestamp unique.

For example:

Timestamp(1406171938, 1) 

So, 1406171938 is the elapsed seconds, 1 is just an ordinal number.