查询中两个时间戳的比较

I want to run a cronjob which check in db table where timespamp is less than current time + 1 month. But not sure how can i do that.

I have tried something but that not works.

$buy_time=strtotime($row['sdate']);
$current_time= strtotime("now");
$diff=$current_time - $buy_time; 

$SQL = "UPDATE product SET status=0 WHERE sdate <'$diff'";
$res= mysqli_query($link,$SQL);

Assuming you're using native mysql date/datetime fields for that sdate field, then don't use PHP to generate dates and paste them into the query, do it all in MySQL directly:

... WHERE sdate >= (NOW() - INTERVAL 1 MONTH)
$currentTime = time();
$timePlusMonth = $currentTime+30*24*60*60; //30 days * 24 hours * 60 minutes * 60 seconds
$timePlusMonth = date("Y-m-d H:i:s", $timePlusMonth);

$query = "UPDATE product SET status=0 WHERE sdate < '$timePlusMonth'";
mysqli_query($link, $query);

your 'sdate' column must be in Y-m-d H:i:s format (2013-08-02 16:02:45)