love
love

Reputation: 1391

PHP Date format

Tue Oct 26 10:39:39 +0000 2010

How to convert format to 2010-10-26

Upvotes: 4

Views: 106

Answers (3)

Matthew
Matthew

Reputation: 48314

Using the DateTime object:

echo date_format(new DateTime('Tue Oct 26 10:39:39 +0000 2010'), 'Y-m-d');

or:

$date = new DateTime('Tue Oct 26 10:39:39 +0000 2010');
echo $date->format('Y-m-d');

Upvotes: 0

Ben
Ben

Reputation: 57318

echo date('Y-m-d');

Upvotes: 0

Vincent Savard
Vincent Savard

Reputation: 35947

echo date('Y-m-d', strtotime("Tue Oct 26 10:39:39 +0000 2010"))
// 2010-10-26

Upvotes: 8

Related Questions