1

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.

4

2 回答 2

1

看看你的问题,你的逻辑似乎是错误的。当前时间总是大于过去的时间。尝试以下操作:

if($time_now>$auction->time_end){
//...
}
于 2013-03-24T13:15:09.443 回答
0

如果您在 32 位系统上,则 int 类型的最大值定义为大约 20 亿。你的两个数字似乎都太大了。请参阅文档

于 2013-03-24T13:05:11.713 回答