日期返回错误的值

时间:2017-05-09 00:43:26

标签: php mysql sql date datetime

我希望其他内容$dayleft"Y/n/j"格式显示,但是当我运行它时,它只返回年份,发生了什么?

代码:

$select = mysqli_query($connect, $query_select);
$row = mysqli_fetch_row($select);
$idchange = $row['5'];
$date = DateTime::createFromFormat("Y-n-j", $idchange);
if (date('Y/n/j', strtotime("-60 days")) > $date){
echo "<br><a href='changeid.php'>Reset Machine_ID</a> - Status: <font color='green'>Available</font>";
}
else{
$dayleft = date('Y/n/j', strtotime("+60 days")) - $date;
echo "<br><a href='#'>Reset Machine_ID</a> - Status: <font color='red'>Unavailable</font> - Available Day: $dayleft";
}

1 个答案:

答案 0 :(得分:0)

您必须格式化计算的最终结果。

error: expected one of `,`, `::`, or `:`, found `.`
  --> src/DepartmentLevels/DepartmentLevels.rs:18:55
   |
18 |         let result = self.professors.iter().fold(0,|sum, self.professors.current_number| sum + self.professors.current_number);
   |                                                       ^ expected one of `,`, `::`, or `:` here

error[E0424]: expected unit struct/variant or constant, found closure capture `self`

<强>更新

这是在PHP小提琴中测试的一个例子:

$dayleft = date('Y/n/j', strtotime("+60 days")) - $date;
$dayleft = date('Y/n/j',$dayleft);
echo "<br><a href='#'>Reset Machine_ID</a> - Status: <font color='red'>Unavailable</font> - Available Day: $dayleft";

这是输出:

  

今天:2017/05/08 09:5:48

     

可用日期:2017/07/07 09:57:48 2017/7/7

     

重置Machine_ID - 状态:不可用 - 可用日期:2017/7/7