Reputation: 3451
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";
}
Upvotes: 0
Views: 41
Reputation: 3312
$NextAuditStamp minus $n is greater than $NowTime
Your test for $Flag = 1
does the opposite, guess you want
if($NextAuditStamp - $n > $NowTime) {...}
Upvotes: 1