Reputation: 427
I've having an issue comparing two unix timestamps in php.
$time_now = mktime();
if($auction->time_end > $time_now){
//true
}
else{
//false
}
$auction->time_end is 1362579127 and set as int from db. $time_now is for example 1364129253 and is set as int, both were checking with var_dump and are indeed returning both as ints.
The problem is that PHP seems to think 1362579127 is greater than 1364129253 (returns false) which it is not.. am I missing something here? If I input the values into the if statement it works as it should but when it's comparing the object it doesn't seem to like it.
Upvotes: 1
Views: 2031
Reputation: 1155
Looking at your question it seems you have the logic the wrong way around. The current time is always bigger then a time in the past. Try the following:
if($time_now>$auction->time_end){
//...
}
Upvotes: 1
Reputation: 2037
The maximum of the int type is defined to be around 2 billion if you're on a 32Bit system. Both of your numbers seem to be too big. See the Documentation.
Upvotes: 0