Danny
Danny

Reputation: 1003

Converting Twitter's date format to Datetime

Twitter's API kicks out a date in this format:

Thu, 18 Oct 2012 09:37:01 +0000

Is it possible to convert this into a datetime format using PHP, for my database? E.g.

2012-10-18 09:37:01

Upvotes: 2

Views: 6006

Answers (2)

jd_7
jd_7

Reputation: 1862

Use the Datetime Object from format

$date = DateTime::createFromFormat('D, j M Y H:i:s +0000', 'Thu, 18 Oct 2012 09:37:01 +0000');
echo $date->format('Y-m-d H:i:s');

Upvotes: 1

Dalen
Dalen

Reputation: 8986

date( 'Y-m-d H:i:s', strtotime("Thu, 18 Oct 2012 09:37:01 +0000") );

Upvotes: 6

Related Questions