Save/Insert timestamps in MongoDB

#1

I need to insert timestamps in MongoDB. I used the Mongo3 driver.

I stated the object like this

"ts": {
"$date:: "2018-10-23T15:23:59.106Z"
}

But on save it says that the field may not contain a $ sign.

#2

Errrr so don’t use a $ sign in the variable name ?

#3

@deejay maybe my post was not clear.

I want to insert a date in MongoDB and have mongo treat it as a date and not a string. I can find in the net that instemde if my duels ta havinf the ISO time string as a value I need to embed a document with $date in it (extended json).

So this was already tovtry to have it inserted as a timestamp. Without that it inserts in MongoDB but as a string even if my timesamp is ISO formatted.