Javascript
theTime = new Date();
$.getJSON("/my_path",{
the_time: theTime,
format: 'json'
});
Python
var the_time = request.GET.the_time
# the entry
entry = {}
# other key/values are added to entry
entry['entry_time'] = entry_time
# the document
new_document = {}
# the entry is nested in the new document
new_document['k1']['n1'].append(entry)
collection.insert(new_document)
MongoDB
When I look at the entry in RockMongo, it is just showing:
"entry_time": "Mon Jan 18 2016 23:59:51 GMT+1000 (AEST)"
But according to this answer:
https://stackoverflow.com/a/3778820/1063287
It should look something like this:
ISODate("2014-02-10T10:50:57.240Z")
How do I insert the Javascript new Date() to MongoDB as an ISODate
via Python?
Edit:
I also just tried this:
Javascript
var theTime = new Date();
var theTime = theTime.toISOString()
$.getJSON("/my_path",{
the_time: theTime,
format: 'json'
});
And it results in this in RockMongo:
"entry_time": "2016-01-18T14:35:09.226Z"