Link to home
Start Free TrialLog in
Avatar of Brad Bansner
Brad Bansner

asked on

Convert date format in PHP to Y-m-d H:i:s

I have been given an XML data feed containing dates which look like this:

<pubDate>Mon, 10 Aug 2015 19:23:30 +0000</pubDate>

I need to convert that into Y-m-d H:i:s for insert via WordPress' wp_insert_post which requires that format. Its very strict, I tried using "8" for August and it errored out, required me to use "08".

My question is, what is the best way to go about this? I could obviously pick it apart piece by piece with a bunch of PHP script but that seems wasteful. Is there a better way?

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Brad Bansner
Brad Bansner

ASKER

Yes! Thank you.
For future reference when working with date/time values in PHP and MySQL:
https://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html