500 - DateTimeZone::__construct() [datetimezone.--construct]

Need help installing Joomla! 2.5? For all Joomla! 2.5 installation issues please use this forum. Note: All 1.6 and 1.7 releases have reached end of life and should be updated to 2.5.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
smallpkgs
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed Dec 23, 2009 9:57 pm

500 - DateTimeZone::__construct() [datetimezone.--construct]

Postby smallpkgs » Sun Sep 18, 2011 4:38 pm

1. We just re-launched the "does this make sense? " site in the same vhosts directory as the old site on our server. The dev site for this was on same server but in a generic html directory.

2. A minority of existing users are see this error:

Code: Select all

500 - DateTimeZone::__construct() [datetimezone.--construct]: Unknown or bad timezone (-5)
You may not be able to visit this page because of:
an out-of-date bookmark/favourite
a search engine that has an out-of-date listing for this site
a mistyped address
you have no access to this page
The requested resource was not found.
An error has occurred while processing your request.
Please try one of the following pages:
Home Page
If difficulties persist, please contact the System Administrator of this site and report the error below..
DateTimeZone::__construct() [datetimezone.--construct]: Unknown or bad timezone (-5)


3. LAMP, Joomla 1.7, installs include latest stable JomSocial, EasyBlog, RSComments (and Rockettheme Tachyon); http://www.doesthismakesense.com

4. JomSocial component is the home page

5. No such error appeared during dev

6. Google searches failed to show a clear answer. IOW, no posts about Joomla 1.7, JomSocial, or any of our tools, and this error. But I do see misc versions of this error, going back years, in more arcane development environments especially.

7. Will happily give login to any qualified person, to help debug this.

8. About to launch several other sites with similar tools and combinations, so I'm worried...

Thanks!

Greg

User avatar
Ripose
Joomla! Explorer
Joomla! Explorer
Posts: 349
Joined: Mon Feb 18, 2008 6:04 am
Location: Lethbridge, Alberta, Canada

Re: 500 - DateTimeZone::__construct() [datetimezone.--constr

Postby Ripose » Sun Sep 18, 2011 11:58 pm

You should ask your host to check php.ini (unless you can access it). You need to change the "date.timezone = -5" line to something like "date.timezone = UTC" or to a specific location like "date.timezone = america/denver"

This answer may not apply to your server.
Ripose
35 Years computer experience!

smallpkgs
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed Dec 23, 2009 9:57 pm

Re: 500 - DateTimeZone::__construct() [datetimezone.--constr

Postby smallpkgs » Tue Sep 20, 2011 1:42 pm

Thanks Ripose. We made that change. The problem continues. An oddity is that if we manually reset a PW and have them log in and out twice, in quick succession -- no kidding -- it SEEMS to go away for good. Which means it's an inherent problem, revealed by certain circumstances. I have my lead developer on this and will report back what we find...

smallpkgs
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed Dec 23, 2009 9:57 pm

Re: 500 - DateTimeZone::__construct() [datetimezone.--constr

Postby smallpkgs » Thu Sep 22, 2011 1:33 pm

We found and applied an answer. When we migrated data using the J2xml importer and exporter tools, it did several things: It did not correctly interpret and import the timezone settings (Joomla 1.7 uses names, older Joomla use -5 or +5 as per UTC); also some user IDs were wrong. We stabilized our DB with queries, and all was resolved. Some users still needed manual PW changes, but no more datetimezone probs!

User avatar
johnhooley7
Joomla! Apprentice
Joomla! Apprentice
Posts: 16
Joined: Mon Oct 18, 2010 10:40 pm
Contact:

Re: 500 - DateTimeZone::__construct() [datetimezone.--constr

Postby johnhooley7 » Mon Oct 31, 2011 4:13 pm

Thanks for posting your solution. I ran into a very similar scenario and this saved me some time and helped to narrow down the problem.

To be more specific in what the issue is and how to fix it:

In Joomla 1.6 the developers implemented a new series of elements having to do with form creation and management. This superseded another, smaller, set of elements, one of which set the timezone for each user. The old set used GMT format in the form of positive and negative floats. For example, -8 meant Pacific LA Time. In 1.6 and later the new system began to use the built-in PHP UTC format settings. For example: America/Los_Angeles instead of -8.

Each user has their timezone settings set in the jos_users database table in the params field. In 1.5 this uses Joomla's old ini format(notice the timezone):

For example:

Code: Select all

editor=
expired=
expired_time=
admin_language=en-GB
language=en-GB
helpsite=
timezone=-8


In 1.6+ this is now json encoded and needs to be (notice the timezone):

Code: Select all

{"editor":"","expired":"","expired_time":"","admin_language":"en-GB","language":"en-GB","helpsite":"","timezone":"America\/Los_Angeles"}


Whatever the migration tool you're using, it needs to parse each user param field, update the timezone to the new version, and json encode it.

Alternatively, if you have a small site, you can probably use the user manager to edit each user's timezone settings and save it to the newest setting.

Not all users have the timezone parameter, but if you execute the following SQL query in your database, you can see who does and needs to be updated(replace 'jos' in `jos_users` with your db prefix):

Code: Select all

SELECT * FROM `jos_users` WHERE `params` LIKE('%timezone%');


The list of timezones:

http://www.php.net/manual/en/timezones.php

The timezone class:

http://www.php.net/manual/en/class.datetimezone.php

GMT to UTC conversions:

http://www.phpbuilder.com/board/showthread.php?t=10359010
A few helpful guides I wrote...
How To Fix a Hacked Joomla Site http://www.bluebridgedev.com/joomla-hacked
and Speed Up Joomla http://www.bluebridgedev.com/speed-up-joomla

BeLlSiBuB
Joomla! Apprentice
Joomla! Apprentice
Posts: 22
Joined: Mon Aug 30, 2010 3:25 pm

Re: 500 - DateTimeZone::__construct() [datetimezone.--constr

Postby BeLlSiBuB » Fri Jan 13, 2012 6:14 pm

I installed Joomla from new and now I have opened the registering system up some users are encountering this error.

500 - DateTime::__construct() [datetime.--construct]: Failed to parse time string (26-05-67) at position 7 (7): Unexpected character

I a a little lost. Is there a solution to stop it happening in the first place?

Created new post about my similar error here:
viewtopic.php?f=622&t=688559&p=2718159#p2718159

stevetdunn
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Fri Jan 27, 2012 9:19 am

Re: 500 - DateTimeZone::__construct() [datetimezone.--constr

Postby stevetdunn » Sat Jan 28, 2012 8:29 am

I had a similar issue with my virgin Joomla 2.5 installation. As part of setup I set timezone to Europe/London. I checked phpinfo() - also Europe/London - however, I noted that the parameters settings in the users table contained Europe\\/London. The SQL below fixed it

update <your prefix>_users
set params='{"editor":"","timezone":"Europe/London","language":"en-GB","admin_style":"","admin_language":"","helpsite":"http:\\/\\/help.joomla.org\\/proxy\\/index.php?option=com_help&keyref=Help16:{keyref}"}'
where id=(I only had a single user - you could leave the where clause out if you have single country only users).

ftb
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Tue Feb 07, 2012 11:32 am

Re: 500 - DateTimeZone::__construct() [datetimezone.--constr

Postby ftb » Tue Feb 07, 2012 11:52 am

I had the same problem. The problem was that the users timezone is set to standard and that the $offset_user in configuration.php wasn't set to our timezone:
public $offset = 'Europe/Amsterdam';
public $offset_user = 'UTC';
I fixed the problem bij changing $offset_user to
public $offset_user = 'Europe/Amsterdam';
Changings in the database weren't necessary.

User avatar
ramnihor
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 114
Joined: Thu Oct 13, 2011 6:05 am
Location: New Delhi
Contact:

Re: 500 - DateTimeZone::__construct() [datetimezone.--constr

Postby ramnihor » Mon Feb 13, 2012 6:27 am

Hi,

I was facing same issue when I change the format of calendar fields type from format="%m-%d-%Y" to [b]"%Y-%m-%d". then the issue resolved. :laugh:

User avatar
NWLB
Joomla! Apprentice
Joomla! Apprentice
Posts: 48
Joined: Mon Jul 30, 2007 3:59 am
Location: Bowling Green, Ohio
Contact:

Re: 500 - DateTimeZone::__construct() [datetimezone.--constr

Postby NWLB » Mon Feb 13, 2012 4:45 pm

ramnihor wrote:Hi,

I was facing same issue when I change the format of calendar fields type from format="%m-%d-%Y" to [b]"%Y-%m-%d". then the issue resolved. :laugh:


This is in the parmeters field?

I simply want to reset the user parameters to a common, working standard at this point. What would be a good query to run? I'm not wise in the ways of such things.
NWLB
*****************************
CruiseAficionados.com

Worsin
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 130
Joined: Mon Sep 18, 2006 1:59 am
Contact:

Re: 500 - DateTimeZone::__construct() [datetimezone.--constr

Postby Worsin » Thu Mar 01, 2012 7:46 pm

bluebridgedev wrote:Thanks for posting your solution. I ran into a very similar scenario and this saved me some time and helped to narrow down the problem.

To be more specific in what the issue is and how to fix it:

In Joomla 1.6 the developers implemented a new series of elements having to do with form creation and management. This superseded another, smaller, set of elements, one of which set the timezone for each user. The old set used GMT format in the form of positive and negative floats. For example, -8 meant Pacific LA Time. In 1.6 and later the new system began to use the built-in PHP UTC format settings. For example: America/Los_Angeles instead of -8.

Each user has their timezone settings set in the jos_users database table in the params field. In 1.5 this uses Joomla's old ini format(notice the timezone):

For example:

Code: Select all

editor=
expired=
expired_time=
admin_language=en-GB
language=en-GB
helpsite=
timezone=-8


In 1.6+ this is now json encoded and needs to be (notice the timezone):

Code: Select all

{"editor":"","expired":"","expired_time":"","admin_language":"en-GB","language":"en-GB","helpsite":"","timezone":"America\/Los_Angeles"}


Whatever the migration tool you're using, it needs to parse each user param field, update the timezone to the new version, and json encode it.

Alternatively, if you have a small site, you can probably use the user manager to edit each user's timezone settings and save it to the newest setting.

Not all users have the timezone parameter, but if you execute the following SQL query in your database, you can see who does and needs to be updated(replace 'jos' in `jos_users` with your db prefix):

Code: Select all

SELECT * FROM `jos_users` WHERE `params` LIKE('%timezone%');


The list of timezones:

http://www.php.net/manual/en/timezones.php

The timezone class:

http://www.php.net/manual/en/class.datetimezone.php

GMT to UTC conversions:

http://www.phpbuilder.com/board/showthread.php?t=10359010


Is there a query script that will change everyones account to the right time zone? I have well over 500 accounts on my site and i would rather not open up each one to hit save (which does work).

User avatar
NWLB
Joomla! Apprentice
Joomla! Apprentice
Posts: 48
Joined: Mon Jul 30, 2007 3:59 am
Location: Bowling Green, Ohio
Contact:

Re: 500 - DateTimeZone::__construct() [datetimezone.--constr

Postby NWLB » Thu Mar 01, 2012 7:52 pm

Worsin wrote:Is there a query script that will change everyones account to the right time zone? I have well over 500 accounts on my site and i would rather not open up each one to hit save (which does work).


I'll echo this question. I have 1500 accounts on one site, 400 on another, etc. I've been looking for something to detail how to run a query to do this, but being Joomla, I don't want to try just anything.

Think of the good Karma that can be yours for the telling! :D
NWLB
*****************************
CruiseAficionados.com

najtrok
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Thu May 12, 2011 12:18 pm

Re: 500 - DateTimeZone::__construct() [datetimezone.--constr

Postby najtrok » Wed May 09, 2012 10:12 pm

Although this is a bit old, I want to add my 2 cents here.

The issue is actually pretty easy to solve. All you need is the old mapping (integers) to the new one (timezone strings).

I only needed one for 0 and 1 but you can easily extend this based on your needs. Heres what you do: Go to a 1.6/1.7 website, Global Configuration, System and check the timezone field in source code. Each option has a value like "UTC". Now go to a 1.5 site and do the same, here the values will be 0, 1, whatever. Manually match each and you can create an array like this:

Code: Select all

 $zones = array( 1 => "Europe/Berlin", 0 => "UTC" );


Finally you can create such an easy code as I did here:

Code: Select all

$db =& JFactory::getDBO();
      
       $query = "SELECT * FROM #__users";
       $db->setQuery($query);
       $db->query();
       $user_list = $db->loadObjectList();
       $zones = array( 1 => "Europe/Berlin", 0 => "UTC" );
      
       foreach($user_list as $user)
       {
      $params = $user->params;
      $params = explode("\n", $params);
      $new_params;
      foreach($params as $param)
      {
          list($key, $value) = explode("=", $param);
          if($key != "timezone")
         $new_params[$key] = $value;
          else
         $new_params[$key] = $zones[$value];
      }
      echo json_encode($new_params) . "\n";

Only thing missing now is saving this to the database instead of making an output. Also if you want to know if you matched all needed timezones, modify your else statement like this:

Code: Select all

else
          {
         if(!in_array($value,  array_keys($zones)))
            echo $value;
         $new_params[$key] = $zones[$value];
          }


This way, it will output all the timezones you need to map in your array. Of course it will output this for every user so you might end with a lot of output. Feel free to optimize it.

User avatar
mojito
Joomla! Guru
Joomla! Guru
Posts: 635
Joined: Wed Sep 07, 2005 10:18 pm
Location: London
Contact:

Re: 500 - DateTimeZone::__construct() [datetimezone.--constr

Postby mojito » Wed Sep 05, 2012 4:17 pm

I had to do a restore from a backup and what saved me was this thread- thanks to you all for posting.
A very cut down config was the result and it was missing a key ingredient

public $offset = 'UTC';

adding that fixed it for me then saving added the full set of other missing items in the config but this one killed the site and backend.
Check out the 'bad toilet' online !


Return to “Installation Joomla! 2.5”

Who is online

Users browsing this forum: No registered users and 3 guests