How to set daylight saving to off in php

2019-05-23 15:31发布

问题:

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');

回答1:

date('I') (that's a capital letter i) returns 1 when the current default time zone is in 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.

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.