I would suggest using the DateTime class
$date1 = new DateTime();
$date1->setTimestamp($timestamp1);
$date2 = new DateTime();
$date2->setTimestamp($timestamp2);
if ($date1->format('Y-m') === $date2->format('Y-m')) {
// year and month match
}
I would highly suggest to anyone learning PHP to learn the DateTime and related classes. They are much more powerful than the basic date functions.