开发者

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

开发者 https://www.devze.com 2023-04-06 10:08 出处:网络
i have this table test : datetid 13159765586224576 13159810826224576 13159764866224576 13159765506224576 what i want is to check the difference in between the dates: 1315981082 - 1315976558, 131597

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

精彩评论

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