Failure when publishing: Exception with message DateTimeZone::__construct()
-
Today I noticed that an error started to occur in the following situations.
1. When I click Publish on a new post.
2. When I click Preview on a private post.Fatal error: Uncaught exception 'Exception' with message 'DateTimeZone::__construct() [<a href='datetimezone.--construct'>datetimezone.--construct</a>]: Unknown or bad timezone (UTC)' in /usr/home/rhyous/public_html/wp-includes/formatting.php:1758 Stack trace: #0 /usr/home/rhyous/public_html/wp-includes/formatting.php(1758): DateTimeZone->__construct('UTC') #1 /usr/home/rhyous/public_html/wp-includes/post.php(2507): get_gmt_from_date('2012-05-07 16:0...') #2 /usr/home/rhyous/public_html/wp-includes/post.php(4885): wp_insert_post(Array) #3 /usr/home/rhyous/public_html/wp-admin/includes/post.php(1274): _wp_put_post_revision(Array, true) #4 /usr/home/rhyous/public_html/wp-admin/includes/post.php(1324): wp_create_post_autosave(4974) #5 /usr/home/rhyous/public_html/wp-admin/post.php(253): post_preview() #6 {main} thrown in /usr/home/rhyous/public_html/wp-includes/formatting.php on line 1758
Fatal error: Uncaught exception 'Exception' with message 'DateTimeZone::__construct() [<a href='datetimezone.--construct'>datetimezone.--construct</a>]: Unknown or bad timezone (UTC)' in /usr/home/rhyous/public_html/wp-includes/formatting.php:1758 Stack trace: #0 /usr/home/rhyous/public_html/wp-includes/formatting.php(1758): DateTimeZone->__construct('UTC') #1 /usr/home/rhyous/public_html/wp-includes/post.php(2507): get_gmt_from_date('2012-05-07 16:1...') #2 /usr/home/rhyous/public_html/wp-includes/post.php(2711): wp_insert_post(Array) #3 /usr/home/rhyous/public_html/wp-admin/includes/post.php(230): wp_update_post(Array) #4 /usr/home/rhyous/public_html/wp-admin/post.php(195): edit_post() #5 {main} thrown in /usr/home/rhyous/public_html/wp-includes/formatting.php on line 1758
I have two blogs hosted on the same server. On Friday, posts worked fine.
Since Friday, on one of the blogs I updated a plugin. I ruled that change out by testing the other blog and by deactivating all plugins. The other blog gets the same error and the same error occurs with all plugins deactivated.
Previous posts on this are two years old and the issue and solution were not relevant.
I can fix this by opening the wp-includes/formatting.php file and changing line 1758 (as noted in the exception) from this:
$datetime->setTimezone( new DateTimeZone('UTC') );
To this:
$datetime->setTimezone( DateTimeZone.UTC );
However, I don’t want to do this everytime WordPress is updated.
Anyone have a better idea what is going on here?
- The topic ‘Failure when publishing: Exception with message DateTimeZone::__construct()’ is closed to new replies.