Php 12 hr format to 24hr time conversion format

I have a line like "6:15 pm". Is there any function in PHP that will convert it directly to a 24-hour format. those. until "18:15"?

+5
source share
3 answers

I would suggest using strtotime()with date():

print date("H:i", strtotime("6:15pm"));
+11
source

You can do this with strtotime():

echo date('H:i', strtotime('6.:15pm'));
+2
source
//Call this once before the 1st date/time operation
date_default_timezone_set('Europe/Zurich');

echo date('H:i', strtotime('6:15pm'));
+1
source

All Articles