dri8163 2019-07-19 08:48
浏览 45

如何在php中设置过期,无效?

I have a problem to define a product which have a expiry date. I want to set a product which it not valid (when $now = date("d-M-y") more than $valid = date("d-M-y", strtotime('+'.$day.' days',strtotime($date)));),

overdue (when $now = date("d-M-y") more than $due = date("d-M-y", strtotime('-30 days',strtotime($valid))); and $now = date("d-M-y") less than $valid = date("d-M-y", strtotime('+'.$day.' days',strtotime($date)));)

valid (when $now = date("d-M-y") less than $valid = date("d-M-y", strtotime('+'.$day.' days',strtotime($date)));)

This is my code :

if ($due > $now && $now > $valid )
{
$vendor ='<td style="color:red;text-align: center;font-weight: bold">'.$rowpur['ven_code'].' (Overdue)</td>';   
}
elseif ($due > $now && $now < $valid )
{
$vendor ='<td style="color:red;text-align: center;font-weight: bold">'.$rowpur['ven_code'].' (Not Valid)</td>'; 
}       
else 
{
$vendor = '<td style="text-align: center;font-weight: bold">'.$rowpur['ven_code'].'</td>';  
}

And the result like a screenshot :

enter image description here

But all that vendor code must be Not Valid

  • 写回答

1条回答 默认 最新

  • doukoumi3389 2019-07-19 09:02
    关注

    You cannot compare dates via the basic < and >. The reason being that they are objects. You can represent the dates by calling the timestamp() method on the object. This will return an integer which can be compared the classical way.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度