I have a string like "6:15pm". Is there any function in PHP which will convert it directly to 24 hr format. ie to "18:15"?
I would suggest using strtotime()
with date()
:
print date("H:i", strtotime("6:15pm"));
You can do this with strtotime()
:
echo date('H:i', strtotime('6.:15pm'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With