Turn on all errors and you will see that you have wrong quotes. Errors would be like
Notice: Use of undefined constant ‘t’ - assumed '‘t’'
This line
$daysInLastMonth = date(‘t’,mktime(0,0,0,$month-1,1,$year));
must be
$daysInLastMonth = date('t',mktime(0,0,0,$month-1,1,$year));