YumYumYum YumYumYum - 29 days ago 7
PHP Question

PHP - why the time is never printing correctly?

Why its printing always invalid time?

PHP 5.5.38 (cli) (built: Aug 21 2016 21:48:49)


Output: 05:11:00
Expected output: 05:00:00

CODE:

date_default_timezone_set('Europe/Luxembourg');
$hour = '05';
$minute = '00';
$time = date('H:m:i', strtotime($hour . ':' . $minute . ':00'));
echo $time;
exit;

Answer

m means "month". It is November, hence 11.

Did you mean date('H:i:s')?