程序中添加时间的初始化语句:“date_default_timezone_set("asia/shanghai");
定义和用法
the date_default_timezone_set() function sets the default timezone used by all date/time functions.
date_default_timezone_set()函数的作用是:设定用于一个脚本中所有日期时间函数的默认时区。
| @@######@@ |
| parameter 参数 |
description 描述 |
|---|---|
| timezone | required. the timezone identifier, like "utc" or "europe/paris". list of valid timezones: http://www.php教程.net/manual/en/timezones.php 必要参数,时区确认器,如“utc”或“europe/paris”。下面列出了有效的时区:http://www.php.net/manual/en/timezones.php |
note: this function always returns true (even if the timezone parameter isn't valid).
注意:这个函数总是返回true(即使时区参数无效的情况下)。
| @@######@@ |
the output of the code above will be:
上述代码将输出下面的结果:
date_default_timezone_set(timezone)
<?phpecho(date_default_timezone_set("europe/paris"));?>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号