4

我想设置应该只存储一天的 PHP COOKIE。设置一天的 cookie 更容易。

如果用户在下午 6 点访问该站点,那么 cookie 应该再设置六个小时。

$tomorrow = mktime(0,0,0,$month,$date+1,$year);

其中月份、日期和年份来自 PHP 日期函数。上面的代码会按我的预期工作吗?

或者有没有更好的方法来做到这一点?

4

1 回答 1

6

尝试使用strtotime()带有tomorrow关键字的函数:

$tomorrow = strtotime('tomorrow');
于 2013-09-11T11:22:26.347 回答