dri8163 2012-05-29 14:36
浏览 87

如何检测从PHP指定的日期过去3小时?

How to detect past 3 hours from the date assigned in php? I have my recent script i don't know if where did I go wrong in my script.

   $currentdate =  "2012-05-29 21:00:01";
   $dateassigned =  "2012-05-29 18:00:00";
   $startTime = mktime() - 3*3600; 
   $getdate = strtotime($date);
   if($getdate >= $startTime) { 
   //if get date already past with 3 hour this will show yes 
    echo "yes"; 
   } else { 
    echo "no"; 
   }

Any help for this problem? Thank you.

  • 写回答

2条回答 默认 最新

  • dosi8657 2012-05-29 14:51
    关注

    not sure if you want comparison up to the second but

    date("now -3 hours");
    

    should return the time
    Tue, 29 May 2012 14:48:01 +000001
    You can use strtotime() to do comparison or date_diff() for php >= 5.3

    评论

报告相同问题?

悬赏问题

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