开发者

php, check the difference in between multiple dates, how to?

i have this table test :

date         tid
1315976558   6224576
1315981082   6224576
1315976486   6224576
1315976550   6224576

what i want is to check the difference in between the dates: 1315981082 - 1315976558, 13159764开发者_C百科86 - 1315981082, 1315976550 - 1315976486, and if the difference is smaller than a day then do something

any ideas on how to accomplish this?

thanks

edit: i know that i want to compare the second with the first and the third with the second, etc, but how do i code it?


Try to use date_diff()

$diff = abs($time2 - $time1);
if ($diff < 60 * 60 * 24){
    //do your stuff
}


select @previous := null;

select datediff(`date`, @previous) as diff, @previous := `date`
from `test`
where diff < 1
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜