How do I to convert a w3c date to a custom format inside PHP?
My w3c date: "2015-02-26T03:11:41.000-03:00" My custom format: "dd/mm/YYYY hh:mm:ss"
Has someone Any idea?
How do I to convert a w3c date to a custom format inside PHP?
My w3c date: "2015-02-26T03:11:41.000-03:00" My custom format: "dd/mm/YYYY hh:mm:ss"
Has someone Any idea?
How about this?
$dateTime = new DateTime('2015-02-26T03:11:41.000-03:00');
echo $dateTime->format('d/m/Y h:i:s');
By using the codes above, it will output:
26/02/2015 03:11:41
It's always suggested to use DateTime
class whenever available, which will have Exception to handle unable parsing cases.
Check out the Docs for date()
// prints something like: Wednesday the 15th
echo date('l \t\h\e jS');
Check out the section about the parameters on the Docs link.
You can try:
$dateTime = new DateTime($dateVar);
$formatted = $dateTime->format("dd/mm/YYYY hh:mm:ss");
You can do it like this:
DateTime::createFromFormat(DateTime::W3C, $your_w3c_date_here)->format('d/m/Y H:i:s');