This question already has an answer here:
i have a string in this format '2015-4-28'
How i get month number for this string ( the value in this example is 4)?
Thanks
</div>
Another option would be to do this:
date('m', strtotime($date));
Change the m to an n to get the month without the leading 0.
With this:
<?php
$a = "2015-4-28";
$parts= explode("-", $a);
echo $parts[0]; // 2015
echo $parts[1]; // 4
echo $parts[2]; // 28
?>