我正在使用 php $_GET 传递日期输入
<form action="trigger_date.php" method="get">
Enter Project Turnover date (mm/dd/yy): <input type="string" name="date"> <input type="submit">
在 trigger_date.php 中将此作为
<?php $turnover_date = $_GET['date']; ?>
我做了一些数学运算以将其与今天的日期进行比较
<?php
$project_turnover = strtotime($turnover_date);
$project_turnover = date ("m/d/y", $project_turnover);
?>
<?php
$datetime1 = date_create($today);
$datetime2 = date_create($project_turnover);
$wks_to_turnover = date_diff($datetime1, $datetime2); // taking the difference between today and project turnover date
$wks_to_turnover = $wks_to_turnover->format('%R%a');
$wks_to_turnover = ($wks_to_turnover/7);
$wks_to_turnover = round($wks_to_turnover,1); //with input of 5/1/14 this should be roughly 24 wks
?>
这就是我难过的地方,我的风格是:
<?php
if ($wks_to_turnover > 2) {
echo $date_green; // colors the background green
} elseif (2 > $wks_to_turnover && $wks_to_turnover > 0) {
echo $date_yellow; // colors the background yellow
} elseif (0 >= $wks_to_turnover) {
echo $date_red; //colors the background red
} ?>;
但即使 (24 > 2) 它仍然是红色的