• 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?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter rhyous

    (@rhyous)

    I did find out that PHP was updated that weekend.

    Is no one else seeing this?

    Thread Starter rhyous

    (@rhyous)

    Ok, the fix actually wasn’t working fully, there have still been exceptions.

    After researching the setTimezone method, PHP says it is optional so I commented it out and so far I haven’t had any more exceptions.

    Just had the same problem, and stumbled on an answer elsewhere in forums.

    Try this:

    In Settings > General set your timezone manually, in my case instead of New York I set it to UTC-4. After the change I was able to Publish posts normally. I changed timezone back to New York and things still work just fine.

    i had same problem. new york – utc-4 and its working ?? thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Failure when publishing: Exception with message DateTimeZone::__construct()’ is closed to new replies.