dsxpt62448 2014-02-19 11:00
浏览 693
已采纳

在php中减去一天的时间方法

I have the following query in some code...

$student_result = db_query("select id,timestamp,time_id,unschedule_code from student where canceled='0' and email='".$email."' and timestamp > '".time()."'");

I want to change and timestamp > '".time()."'"); to time - 1 day. I tryed something like...

$student_result = db_query("select id,timestamp,time_id,unschedule_code from student where canceled='0' and email='".$email."' and timestamp > '".time(). - 1"'");

...with no luck. Page simply fails to load, so I'm sure the syntax is not even valid. Any help appreciated...

  • 写回答

1条回答 默认 最新

  • dre75230 2014-02-19 11:03
    关注

    Timestamps are in seconds, try:

    $student_result = db_query("select id,timestamp,time_id,unschedule_code from student where canceled='0' and email='".$email."' and timestamp > '".(time()-(3600*24))."'");
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部