例(未テスト):
スタイルシートで定義します。
.before { background-color: #FF9999; }
.current { background-color: #FF0000; }
.after { background-color: #FFFFFF; }
あなたのPHPで:
$iNow = time();
$iDeadline = strtotime($sMySqlDate);
$iAfter = strtotime('+1 day', $iDeadline);
$iBefore = strtotime('-10 days', $iDeadline);
$sClass = ($iNow >= $iAfter ? 'after' : ($iNow < $iBefore ? 'before' : 'current'));
echo '<div class="' . $sClass . '">...</div>';
===更新===
mysqlデータベースからのタイムスタンプの読み取り:
$sSql = "SELECT `closedate` FROM `table`";
$rResult = mysql_query($sSql);
if (!$rResult) {
echo "Could not successfully run query ($sSql) from DB: " . mysql_error();
exit;
}
$aRow = mysql_fetch_assoc($rResult);
$sMySqlDate = $aRow['closedate'];
mysql_free_result($rResult);