I have a string in this format:
Thu, 26 Feb 2015 11:39:59
And I wonder if its possible to transform it to a valid timestamp format in order to insert it in my PostgreSQL database.
So ideally in the end I would have something like:
2015-03-26 11:39:59
Is there a function in PHP to do something like this?
Use DateTime()
to format date string.
$date = 'Thu, 26 Feb 2015 11:39:59';
$date = new DateTime($date);
echo $date->format('Y-m-d H:i:s');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With