22

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

2
  • My answer hasn't helped you? Commented Sep 8, 2016 at 11:29
  • I'm currently having the same problem in Magento 2.1.3. The homepage works, but all other pages don't. My timezone is properly set in core_config_data to Europe/Amsterdam. Commented Jan 19, 2017 at 14:18

4 Answers 4

66

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.

9
  • 10
    I had the exact same problem. I mistakenly added a new line in the core_cofig_data table while trying to insert some entries for something different. I'm using SequelPro app on Mac and when I add a new row it automatically adds general under path
    – Alex Dinca
    Commented Feb 28, 2017 at 20:16
  • 2
    yup, same issue for me a quick easy way to get rid of it for future reference:DELETE FROM core_config_data WHERE path LIKE 'general' AND value IS NULL LIMIT 1;
    – B00MER
    Commented Mar 21, 2017 at 8:41
  • 2
    It worked as a charm, and don't forget to clean cache after deleting the "general" "NULL" line in the database ;)
    – Alex
    Commented Aug 14, 2017 at 9:02
  • 1
    I can say this issue with blank/null values in core_config_data with path = 'general' has been an issue that even Magento 1 suffered from.
    – Rand
    Commented Aug 20, 2019 at 21:04
  • 1
    Same happend to us - we have no idea how. This answer was a lifesaver! Commented Oct 8, 2020 at 12:54
9

The timezone should be one of the List of Supported Timezones. Seems that you are using empty timezone.

Try to detect the current store timezone using the next query:

SELECT * FROM `core_config_data` WHERE `path` = 'general/locale/timezone'

If result is empty, try to insert the default value:

INSERT INTO `core_config_data`(`path`, `value`) VALUES ('general/locale/timezone', 'Europe/Moscow')

If this does not help - try to search inside the project: where the code throws an error. Then try to debug it: detect from where the empty timezone value is coming.

2
  • I Have just revert back my old website by reverting backup .and we are working on deadline so I have not checked the issue which causing the issue But thank you for your answer. I have upvoted your answer and i will check If it is the same issue then I will Mark your answer as accepted Commented Sep 8, 2016 at 11:40
  • I faced this issue in a vanilla setup of 2.3.0 and solved it using above solution. Thanks @Siarhey Commented Apr 11, 2019 at 10:11
1

I solved the problem with the correct answer;

1,Select TO:

select * FROM `core_config_data` WHERE path = 'general'

2,Delete TO:

DELETE FROM `core_config_data` WHERE path = 'general'

Then the website is working, I hope to be useful to you.

1
  • Giel Berkers already answered the same what new you answered ?? Commented Oct 15, 2019 at 5:44
0

the other cause of this is if your server is maxing out flash memory and is out of phyical memory. I was running three magento dev sites on one box and had this issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.