Reputation:
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;
Upvotes: 0
Views: 69
Reputation: 485
Whenever print time then date format like (H:i:s)
date_default_timezone_set('Europe/Luxembourg');
$hour = '05';
$minute = '15';
$time = date('H:i:s', strtotime($hour . ':' . $minute . ':00'));
echo $time;
exit;
Make sure this is a helpful to you
Upvotes: 0
Reputation: 38
In your date() call, you're specifying: H - 24-hour format of an hour with leading zeros. m - Numeric representation of a month, with leading zeros. i - Minutes with leading zeros.
And this is indeed November, the 11th month.
Upvotes: 1
Reputation: 1
You used m in date, thats why. You should use i instead of m:
m - Numeric representation of a month, with leading zeros - 01 through 12
i - Minutes with leading zeros - 00 to 59
You can check how to format here: http://php.net/manual/en/function.date.php
Upvotes: 0
Reputation: 324610
m
means "month". It is November, hence 11.
Did you mean date('H:i:s')
?
Upvotes: 10