This will be the way to do this:
$dateString = '2010-02'; list($year, $month) = explode('-', $dateString); $timeStamp = mktime(0, 0, 0, $month, 1, $year); echo date('F, Y', $timestamp);
Another way:
$dateString = '2010-02'; $timestamp = strtotime($dateString . '-01'); echo date('F, Y', $timestamp);
strtotime cannot handle ambiguous dates such as "2010-02", but if you make a full date, it should work.
Otherwise, you may need to look at something like DateTime::createFromFormat .
source share