如果时间到了,我写出了一个脚本来将用户的密钥活动状态更改为0。当我开始的时候,我把start_time
设置为time();比设定“60”的时间要多少天。用这个计算剩余时间?
根据我目前的做法,我如何计算一天或几小时或几分钟剩余的时间?
$user_info['days'] = "60"
`start_time` = 1332219600
function setup() {
mysql_connect('localhost', 'stresser_main', 'ZLLAUkuLIUU');
mysql_select_db('stresser_main');
$query = mysql_query("SELECT * FROM `keys` WHERE `active`='1'");
while ($user_info = mysql_fetch_array($query)) {
$time_ago = strtotime("-" . $user_info['days'] . " day");
$time_ago_other = strtotime("+" . $user_info['days'] . " day");
mysql_query("UPDATE `keys` SET `active`='0' WHERE `start_time` < $time_ago AND `id`='" . $user_info['id'] . "'");
}
}
'的strtotime();'可以采取两个参数,第二个是时间戳,即是起点(它会默认到现在),所以如果你做'的strtotime(“+ 60天”的,1332219600) ;'它会告诉你到期的时间戳 – Waygood 2013-03-19 11:32:49