I want to get only the date from an array containing a datetime string.
Array is:
print_r($incomplete);
Output:
Array
(
[0] => 2015-09-21 11:20:37
)
And I want in below Format,
Array
(
[0] => 2015-09-21
)
I have tried like this,
echo date('Y-m-d',strtotime($incomplete));
The date conversion code works. What you have in $incomplete is an array, so you will have to use $incomplete[0] to access that value. Easy solution for that would be this:
$incomplete[0] = date('Y-m-d',strtotime($incomplete[0]));
Now you have the same array data without the time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With