Magento2 Error – Fix Unknown or Bad Timezone Issue

errormagento2timezone

enter image description here

When i am accessing my magento website i am getting errors

DateTimeZone::__construct(): Unknown or bad timezone ()

on Block and CMS pages and all my product list pages on frontend shows 404 page not found error. Please check and help me out to fix this issue ASAP.
You can check this problem at here.
I solve this error by restoring my backup site.

But if you know why this error is coming then this question is still open

Best Answer

I don't know exactly HOW it happened, but in my scenario the core_config_data table was corrupted. It had added a new row somehow with path set to general and value set to NULL:

wrong configuration in database

This caused Magento\Framework\App\Config\ScopeConfigInterface::getValue() on public/vendor/magento/framework/Stdlib/DateTime/Timezone.php::scopeDate() to return NULL instead of Europe/Amsterdam. Needless to say, when the \DateTimeZone() object was created it immediately threw this exception.

So if anyone else encounters this error, your configuration might be an obvious place to start looking.

Related Topic