我想设置PHP COOKIE,它应该只存储一天。将 cookie 设置为一天更容易。
如果用户在下午 6 点访问该网站,则 cookie 应仅设置为另外六个小时。
$tomorrow = mktime(0,0,0,$month,$date+1,$year);
其中月、日和年来自 PHP 日期函数。上面的代码会按我的预期工作吗?
或者有更好的方法可以做到这一点吗?
尝试将 strtotime()
函数与 tomorrow
关键字一起使用:
$tomorrow = strtotime('tomorrow');