Q:

get date from dateTime in PHP

I want to extract date without time from a single value from array result thaht I got.
I tried using array_slice but it didn't work.
My code..
    $dateRows = $this->get('app')->getDates();
    $dateRow = json_decode(json_encode($dateRows[0], true));

    dump($dateRow[0]);die;

And I got result..

"2014-01-01 00:00:00"

And I want it to return just

"2014-01-01"

A:

Very Simple, just use date_create() on your date & then format it using date_format() as follows -
$date = date_create("2014-01-01 00:00:00");
echo date_format($date,"Y-m-d");

So, in your case, it would be something like - 
$date1 = date_create($dateRows[0]);
echo date_format($date1,"Y-m-d");

