Reputation: 10542
Hey all i have this date for one of my twitter feeds:
Tue Apr 16 17:39:59 +0000 2013
Problem is that this code below does not seem to format it?
$date = new DateTime('Tue Apr 16 17:39:59 +0000 2013');
echo $date->format('Y-m-d H:i:s');
It just shows up as a blank page.
What could i be doing wrong?
Upvotes: 0
Views: 422
Reputation: 1
i've tested out your code on a console app with php and works fine. I think that maybe you have a problem with the code that display the page in the browser. Other thing that you can try is to inspect the source of the page and see if is showing there. BTW, i'm using PHP 5.4.7
Upvotes: 0
Reputation: 2225
Try this
$date = 'Tue Apr 16 17:39:59 +0000 2013';
echo gmdate('Y-m-d H:i:s', strtotime($date));
Upvotes: 0
Reputation: 219794
Try:
$date = DateTime::createFromFormat('D M j H:i:s O Y', 'Tue Apr 16 17:39:59 +0000 2013');
echo $date->format('Y-m-d H:i:s');
Upvotes: 5