What is this doing in particular
date ('d M Y', $row["timestamp"]);
Its located just under the first if Statement, and is getting any output.
if ($testtime < $nowtime) {
Is $testtime set in the past or future? As the if statement will run if $testtime is less than $nowtime if not the else should run.