I am consuming an XML feed that dumps an attribute of dateacquired
and the date that is "2014-3-28 6:08 AM"
.. I am needing to use this attribute and it's date in my Mongo DB, but I am not sure how to convert it to a date that is usable (e.g. for date based queries).
You can use DateTime::createFromFormat()
to translate the date into a DateTime object and then alter its format use DateTime::format()
$date = DateTime::createFromFormat('Y-n-d h:i A', '2014-3-28 6:08 AM');
echo $date->format('Y-m-d H:i:s');