Get month of a given date which is stored in a PHP time variable in 'Y-m-d' format
The getMonth() method returns the month in the specified date according to local time, as a zero-based value (where zero indicates the first month of the year).
Try date_parse_from_format()
:
$date = "2010-08-12";
$d = date_parse_from_format("Y-m-d", $date);
echo $d["month"];
$date = "2010-10-10";
echo date("m", strtotime($date))?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With