Convert 12 Hour Time to 24 Hour Time using PHP

DateTime::format method

<?php

$timeIn12HourFormat = '5:30 PM';

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

echo $timeIn24HourFormat;

Leave a Comment

Cancel reply

Your email address will not be published.