I have this string from database - "08:30AM-09:30AM" I want to make the string to 24H like this - "20:30-21:30" Thank you! Its Sentence (String Value)
CodePudding user response:
First you need to use 'H' for get the hours on 24h format.
Second in this case, i propose to separate the hours first and come back together after change the date format like this:
$from_database='08:30AM-09:30AM';
$hours=explode('-',$from_database);
echo date('H:i',strtotime($hours[0])).'-'.date('H:i',strtotime($hours[1]));
This always will work meanwhile you don't change the date format that you recive from database.