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

在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...

图片转代码服务由CSDN问答提供 功能建议

我在某些代码中有以下查询...

  $ student_result = db_query(“select id,timestamp,time_id,unschedule_code from student where cancelled ='0'and email ='”。$ email。“'and timestamp>'”。time()。“'”);  
   
 
 

我想更改时间戳> '“.time()。”'“);到时间 - 1天。我尝试了类似......

  $ student_result = db_query(”select id,timestamp,  time_id,unschedule_code来自学生,取消='0',电子邮件='“。$ email。”'和timestamp>'“。time()。 -  1”'“); 
    
 
 

...没有运气。页面无法加载,所以我确信语法甚至无效。任何帮助都赞赏...

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dre75230 2014-02-19 19: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))."'");
    
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题