Here this blog is about, how to change date time format 12hr to 24 hrs and vice-versa.
I have given a simple examples which makes you better understand.
1 2 3 4 5 6 7 | <?php $booking_to_time = "4:45 PM"; $booking_date = "2020-12-01"; $time_in_24_hour_format = date("H:i:s", strtotime($booking_to_time)); $booking_date_time = $booking_date.' '.$time_in_24_hour_format; $total_seconds = strtotime($booking_date_time); ?> |
Note:-
1 2 3 4 | // 24-hour time to 12-hour time $time_in_12_hour_format = date("g:i a", strtotime("16:45")); // 12-hour time to 24-hour time $time_in_24_hour_format = date("H:i", strtotime("4:45 PM")); |