mongo's go driver returns a bson timestamp as https://godoc.org/go.mongodb.org/mongo-driver/bson/primitive#Timestamp is there a way to convert it to time.Time
https://docs.mongodb.com/manual/reference/bson-types/#timestamps
As you can see in mongodb official website, BSON Timestamps contains two values, 'T' for the seconds since Unix epoch and 'I' for an incrementing ordinal for operations within a given second.
So if you want to convert the bson timestamp to time.Time, you may just use time.Unix(timestamp.T, 0)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With