dousong3760 2017-11-01 21:20
浏览 72
已采纳

逻辑循环包含时间戳的记录

I need help with some logic when handling timestamps.

I have a table with a few hundred records, each record has a field witch contains a timestamps. I have $NextAuditStamp, this field is populated via a user input script which converts dates to timestamps.

Now I need to loop through each record and return all the records where the $NextAuditStamp minus $n is greater than $NowTime. Here is the test code I am currently work with to try and get the logic working:

$NowTime = time();

$Flag = "";

$n =  2635250; // this is a fixed timestamp representing 1 month

$NextAuditStamp = strtotime($_POST['NextAuditDate']);

if($NowTime - $n > $NextAuditStamp) {
    $Flag = 1;
} elseif($NowTime > $NextAuditStamp) {
    $Flag = 2;
} else {
    $Flag = "0";
}
  • 写回答

1条回答 默认 最新

  • duanji1043 2017-11-01 21:45
    关注

    $NextAuditStamp minus $n is greater than $NowTime

    Your test for $Flag = 1 does the opposite, guess you want

    if($NextAuditStamp - $n > $NowTime) {...}
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?