Convert 24 Hour Time to 12 Hour Time using PHP

DateTime::format method

<?php

$timeIn24HourFormat = '17:30';

$dateTime = new DateTime($timeIn24HourFormat);
$timeIn12HourFormat = $dateTime->format('g:i A');

echo $timeIn12HourFormat;

Leave a Comment

Cancel reply

Your email address will not be published.