Over a million developers have joined DZone.

Fixing the Year 2038 Problem on Magento 2

DZone's Guide to

Fixing the Year 2038 Problem on Magento 2

Magneto 2 has a bug that causes dates later than 2038 to be rolled back. This won't be an issue when 2038 actually rolls around, but it can present some issues now.

· Web Dev Zone ·
Free Resource

Access over 20 APIs and mobile SDKs, up to 250k transactions free with no credit card required

In Magneto 2, the time beyond the year 2038 will wrap around and be stored internally as a negative number, which the system will interpret as having occurred on December 13, 1901, rather than January 19, 2038. This problem is similar to the Millennium Bug.

Of course, by that time, all the servers will be upgraded to avoid the issue, but let’s see how this problem may affect your time-sensitive settings in Magento 2.

If you accidentally choose the longest valid period possible for a coupon, it won’t work. This issue is also present on Magento 1, but it’s easier to choose the max period in Magento 2 thanks to the interface:

Image title

Now, the coupon stops working because Magento, as all other platforms working on MySQL can’t accept and store dates after 2038 in the timestamp fields.

If we set a date later than the year 2038, it just slips to the year 1970, leaving us with an invalid coupon or any other feature that uses the timestamp fields.

To avoid this issue, I implemented an extension, which helps to avoid such accidents. In the future, such fixes won’t be needed, as the issue will be solved on a server level.

The extension simply makes it impossible to choose any dates after the year 2037 in your Magento 2. Technically, this is not a fix, but it is a workaround to avoid accidental issues with all the Magento 2 features that are using dates. Instead of explaining the issue to all the store managers, you can simply install this extension and be sure everything works.

Feel free to download the extension or share it with your fellow Magento 2 users and developers.

#1 for location developers in quality, price and choice, switch to HERE.

magento 2 ,performance ,bug fix

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}