Home  >  Q&A  >  body text

How to force PHP to ignore daylight saving time?

<p>I have some web applications running on PHP 7.4.26 on a Windows server. This year (2023) the Mexican government decided to stop using Daylight Saving Time (DST), which caused me problems. My web application requires the America/Mexico_City time zone, but PHP continues to use DST, adding unwanted extra time. I was able to change the Windows server time to ignore DST. Therefore, the server has the appropriate time. But PHP always gives wrong results. I cannot modify the server to reduce it by one hour (as a workaround) since it is used for other non-PHP applications. How do I force PHP to ignore DST so I can continue to use the correct time zone? Thank you so much. </p>
P粉348915572P粉348915572385 days ago646

reply all(1)I'll reply

  • P粉471207302

    P粉4712073022023-09-04 10:34:44

    Unfortunately, you will not be able to change the time zone DST without upgrading to PHP 8.

    PHP contains the IANA time zone database and is regularly updated with newer versions of PHP.

    As you can see on the IANA mailing list, Mexico did not add the change to eliminate daylight saving time until the 2022e release in October 2022.

    As this 3v4l shows, there is no version of PHP 7 bundled with the timezone database that contains the following changes for Mexico. The minimum version you need is 8.0.26, 8.1.13, or 8.2. Since PHP 7 has been discontinued and is no longer receiving any updates, now is a good time to upgrade.

    reply
    0
  • Cancelreply