I'm creating a PHP website and I have to test a date to know if minutes == 00, 15, 30 or 45
To enter the date I use a datetime-local input in the HTML form.
Unfortunately when I try to get the minutes it always returns "33"
Here is my code :
$d=date('Y-m-d H:i:s', strtotime($date_deb));
echo $d.'<br />'.date(i,$d);
it returns:
2013-08-18 12:05:00
33
You don't need to use the date
function again. Just use:
echo date('i', strtotime($date_deb));
There is reason why you got 33, it's mainly because your passed a date time string into the date
function second param. it expects a since epoch seconds
value.
you can get the value you need from the first statement it self.
$d=date('i', strtotime($date_deb));