判断用户今天是否已(转发)
一、
把用户转发时间戳存进数据库(shareTime字段)
二、
从数据库查询该用户上次转发时间戳
三、
与今天00:00时间戳作比较,数据库时间戳小于今天00:00时间戳,则表示今天未(转发)
今天00:00时间戳获取方法:
$today = strtotime(date('Y-m-d',time())); // 今日凌晨00:00 时间戳
if ($share < $today) {
echo "今日未转发";
}
注: TP5可以直接使用时间查询
$share = Db::name('data') -> whereTime('shareTime', 'today') -> count();
if ($share == 0) {
echo "今日未转发";
}