date is not getting saved as ISODate in mongodb, though looking at users table I can see the timestamp dates are being saved in correct format. But for some reason when I try to save date it gets save in the below format:
"date_departure" : {
"date" : "2016-07-14 17:50:17.000000",
"timezone_type" : 3,
"timezone" : "UTC"
}
which actually should be in a format like "date_departure" : ISODate("2016-07-13T06:43:12.998Z")
Pls suggest a fix!
i changed my data, move date to root document and add this line on my model file "protected $dates = ['created_at', 'updated_at', 'datetime']" and then try to update all document and move date from child doc. to root but its not working when you use eloquent update method, then i delete document and create again with root datetime field. its worked for me.
Assumption collection name is _Event_ .
use Event->save() not Event::insert($array) .
Also add line "protected $dates = ['created_at', 'updated_at', 'datetime']" on model file
use_this_value = new \MongoDB\BSON\UTCDateTime($datetime_object);
Most helpful comment
Assumption collection name is _Event_ .
use Event->save() not Event::insert($array) .
Also add line "protected $dates = ['created_at', 'updated_at', 'datetime']" on model file