我在脚本中用于获取日期的以下代码
<?php echo date("Y-m-d", strtotime("tommorow")); ?>
<?php $tomorrow = mktime(0, 0, 0, date("m"), date("d")+1, date("Y")); echo "".date("Y-m-d", $tomorrow); ?>
现在我在php 5 中得到错误
It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone
只需在脚本顶部设置时区,例如伦敦:
date_default_timezone_set("Europe/London");
PHP 5.1对mktime
函数进行了一些更改,因此如果未设置时区,它将引发错误。您可以在此处阅读相关文档:http://php.net/manual/en/function.mktime.php
如果PHP没有设置默认时区(自PHP5以来),则对日期函数的每次调用都会生成E_WARNING消息。
您必须至少执行以下操作之一:
- 使用date_default_timezone_set设置当前脚本的时区,或者
- 使用php.ini中的date.timezone配置变量为所有脚本设置默认时区
从支持的时区列表中选择您的时区。