如何在PHP中将夏令时设置为关闭 [英] How to set daylight saving to off in php

查看:275
本文介绍了如何在PHP中将夏令时设置为关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这行代码将夏令时设置为开,这是将其设置为关的正确方法

I've got this line of code which set daylight saving "On" what would be the proper way to set it to "off"

// is daylight saving On?
$rcmail_config['dst_active'] = (bool)date('I');


推荐答案

date('I' )(即大写字母i)在当前默认时区在DST中。

date('I') (that's a capital letter i) returns 1 when the current default time zone is in DST.

如果返回1而不是0 并且所涉及的时区不是在DST 中,您选择的时区不正确或使用的时区数据已过期。

If it's returning 1 instead of 0 and the timezone in question is not in DST, either the timezone you've picked is incorrect or the time zone data it uses is out of date.

如果可以的话,请尝试将 DateTime对象 DateTimeZone对象,它一直是设置为适当的时区 format('I') 调用生成的对象应该是正确的。如果不是,则您的时区数据已过期。有时这是在服务器级别完成的。请确保服务器的时区数据库是最新的。 PHP有时会包含其自己的时区数据文件,因此您可能需要实际更新PHP。

If you can, please try using a DateTime object with a DateTimeZone object that has been set to the proper time zone. A format('I') call on the resulting object should be correct. If it isn't, then your time zone data is out of date. This is sometimes done at the server level. Please ensure that the server's time zone database is up to date. PHP sometimes includes it's own time zone data file, so you may need to actually update PHP instead.

这篇关于如何在PHP中将夏令时设置为关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆