How do insert a Date before the year 1900 into MongoDB from PHP? To be more precise, I need to start from a date string, e.g. "03 Aug 1492" and insert it into a collection as an ISODate object.
Handling dates before 1900 in PHP is done using DateTime. I can easily create a DateTime object from my date string:
$date = DateTime::createFromFormat('d M Y', '21 Feb 1554');
But how do I get from there to a correct insert, e.g.:
$db->collection->insert([
'name': 'Jon Doe',
'date': $isoDate
])
In other words, how do I convert my $date
into an ISODate object (not a string)?