I'm working with an API that returns timestamps in this format:
07/23/2017 23:39:21
The format is: MM/DD/YYYY HH:MM:SS
I need to covert this string so it displays in this format on my webpage:
23 July 2017, 11:39pm
Is this possible?
I'm working with an API that returns timestamps in this format:
07/23/2017 23:39:21
The format is: MM/DD/YYYY HH:MM:SS
I need to covert this string so it displays in this format on my webpage:
23 July 2017, 11:39pm
Is this possible?
You can do this :
$date = new DateTime('07/23/2017 23:39:21');
echo $date->format('d F o, h:ia');
Output :
23 July 2017, 11:39pm
Take a look at http://php.net/manual/de/datetime.createfromformat.php. You'll get a DateTime object which you can convert in the format you desire.
Like so:
<?php
$date = DateTime::createFromFormat('m/d/Y H:i:s', '07/23/2017 23:39:21');
echo $date->format('d M Y, h:ia');
?>