$date = substr($lastupdate, 0, 10); // will remove the time
$date_ = explode('-', $date);
$day = $date;
This is not ideal. What version of php are you running. The latest version (php 5.3) has some very cool and easy to use date manipulation functionality. Or you could use Zend_date to achieve the same. Else I would convert it to a unix time stamp and do the calculation from there.