This question already has an answer here:
I want to convert my date from GMT to simple Date format , i look around on many questions and answers on this site but not succeed.
I have Date
$date = '2010-12-01T02:00:00:000-0500';
and I want to convert this date to 12-01-2010
, i already tried with the date('d-m-Y',strtotime($date));
but it not work here.
Thanks in Advance.
</div>
This should work for you:
Just use DateTime::createFromFormat()
to create a DateTime
object out of your formatted date, like this:
$date = "2010-12-01T02:00:00:000-0500";
$date = DateTime::createFromFormat("Y-m-d\TH:i:s:uP", $date);
echo $date->format("m-d-Y");
output:
12-01-2010