php - MYSQL TIME without secondsGet the solution ↓↓↓
In PHPmyAdmin I stored times with TIME function. They are displayed as hh:mm:ss. With PHP I want to remove the seconds and use following script:
$startTime = $row["open"]; $print_time = date("H:i", strtotime($startTime));
It returnes "01:00", the seconds are removed, but the time should display "11:50" or "14:17", per example.
date("H:i", strtotime($startTime)); returns
strtotime($startTime) returns a value 0-60.
false (0) when
$startTime doesn't match a valid time format as described at https://www.php.net/manual/en/datetime.formats.time.php.
$startTime = '06:00:00'; $print_time = date("H:i", strtotime($startTime)); var_dump($print_time);
$startTime = 'invalidformat'; // E.g. $startTime = false; $print_time = date("H:i", strtotime($startTime)); // strtotime($startTime) returns false var_dump($print_time);
Please double check the value of
People are also looking for solutions of the problem: composer detected issues in your platform: your composer dependencies require a php version ">= 8.0.2".
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.