Title: Uncaught exception: DateTime::__construct()
Last modified: August 21, 2016

---

# Uncaught exception: DateTime::__construct()

 *  Resolved [ditler](https://wordpress.org/support/users/ditler/)
 * (@ditler)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/uncaught-exception-datetime_construct/)
 * Hey everyone,
 * I have a strange issue here, and no idea where it came from:
 * When I show the amr events lists widget to a logged in user, I get the error 
   below. This does not occur for logged-out users nor on a special events page.
 * I use the amr-pluggable extension, but it works correctly and can be ruled out
   as the origin of the problem (persists even when pluggable plugin deactivated).
 * My timezone is set correctly and the plugin does recognize it, I guess. It says
   _Current time (unlocalised): Fri, 27 Jun 2014 12:38:08 +0200_ when my time is
   12:38 in German time.
 * Thank you!
 * The error message:
 *     ```
       Uncaught exception: DateTime::__construct() [datetime.--construct]: Failed to parse time string (Do 26 Jun 2014 13:15:17 UTC) at position 0 (D): The timezone could not be found in the database 
   
       An error in the input data may prevent correct display of this page. Please advise the administrator as soon as possible.
       ```
   
 * [https://wordpress.org/plugins/amr-ical-events-list/](https://wordpress.org/plugins/amr-ical-events-list/)

Viewing 10 replies - 1 through 10 (of 10 total)

 *  Plugin Author [anmari](https://wordpress.org/support/users/anmari/)
 * (@anmari)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/uncaught-exception-datetime_construct/#post-5047949)
 * Hi that does sound weird – widget shouldn’t care whether a user is logged in 
   or not. And uses much of the same code as the short odd.
    The only thing I can
   think of is that something else is interfering and/OR that the order of execution
   is causing a difference.
 * Try in a default wordpress theme or in a footer sidebar and see if that is any
   different.
 * There was a recent change with timezone BUT nothing to do with logged in/not 
   logged in. Unless you have a plugin that sets time by user timezone ?
 *  Thread Starter [ditler](https://wordpress.org/support/users/ditler/)
 * (@ditler)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/uncaught-exception-datetime_construct/#post-5047987)
 * For one reason or another, after two days, the problem just disappeared. Maybe,
   after all, it does have something to do with caching in some sense, or maybe 
   there was just a temporary issue with the icals from google.
 * The only downside: I will not be able to analyze the issue further.
 * Thanks however for your quick reaction!
 *  Thread Starter [ditler](https://wordpress.org/support/users/ditler/)
 * (@ditler)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/uncaught-exception-datetime_construct/#post-5048037)
 * Hey!
    It appeared again. Does not seem to have anything to do with the login/
   logout though. The problem appears e.g. here: [http://www.corps-arminia.de/veranstaltungen/](http://www.corps-arminia.de/veranstaltungen/)
   I had suspected Total Cache and Widget Logic plugins, but deactivating them does
   not change anything. Also with Twenty Twelve clean theme the problem persists.
   Any help appreciated!
 *  Plugin Author [anmari](https://wordpress.org/support/users/anmari/)
 * (@anmari)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/uncaught-exception-datetime_construct/#post-5048038)
 * Hi, just letting you know I am looking at this. I’ve tried to recreate the problem
   on my site but so far cannot. I used your ics files which I think are:
    [http://www.google.com/calendar/ical/e32poekhjpcuuteardecuhe3qg%40group.calendar.google.com/private-7f10a7c52ce10a31c3e5ce07362c0feb/basic.ics](http://www.google.com/calendar/ical/e32poekhjpcuuteardecuhe3qg%40group.calendar.google.com/private-7f10a7c52ce10a31c3e5ce07362c0feb/basic.ics)
   and [http://www.google.com/calendar/ical/f0a3dn32ersja9hibaq9ec0f50%40group.calendar.google.com/private-0e04f34f47ae4fb793df8ddc78cf6d61/basic.ics](http://www.google.com/calendar/ical/f0a3dn32ersja9hibaq9ec0f50%40group.calendar.google.com/private-0e04f34f47ae4fb793df8ddc78cf6d61/basic.ics)
 * > Failed to parse time string (Mo 07 Jul 2014 19:57:32 UTC) at position 0 (M):
   > The timezone could not be found in the database
 * Looking at the message it is trying to parse a “current date/time” – maybe “now”
   and complaining about the timezone.
 * What is your wp timezone?
 * There was a php bug a while back where php failed to cope with timezones and ‘
   case’ (upper/lower). Unlikely but Can you advise version of PHP just in case?
 * It looks like it doesn’t happen when it is NOT on the events page ? Is that correct?
   Is it the same widget instance or a different one ?
    [http://www.corps-arminia.de/news/](http://www.corps-arminia.de/news/)
   vs [http://www.corps-arminia.de/veranstaltungen/](http://www.corps-arminia.de/veranstaltungen/)
 * perhaps whatever you are using to create that main event listing is interfering?
 * what else is different about those 2 pages?
 *  Plugin Author [anmari](https://wordpress.org/support/users/anmari/)
 * (@anmari)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/uncaught-exception-datetime_construct/#post-5048039)
 * Hi Ditler,
    I have spent quite some time trying to see what could be causing 
   it. I cannot create the problem myself, not even on a german version with your
   ics file [http://lang.icalevents.com/kommende-veranstaltungen/?lang=de](http://lang.icalevents.com/kommende-veranstaltungen/?lang=de)
 * It seems to me that it is complaining about an a expanded/ translated current
   date and time string. However in searching through the code, the plugin does 
   not attempt to create a date like that anywhere.
 * It is possible that this is something unique to your site. as noted before it
   only seems to happen when the widget is in sidebar on the one page, not on other
   pages. Puzzling.
 * In the next update I have aded more exception traps to try to trap the fatal 
   error that it is causing and handle it more graciously – perhaps that will shed
   some light.
 * I also googled the problem. I thought perhaps it was a non-english language related
   issue but could not find much helpful. There are other php sites that report 
   similar messages where the cause/solution appears to have nothing to do with 
   datetime.
 * EG some joomla sites report similar errors and it appears to be totally unrelated
   folder permissions error, unwriteable directories.
 * [http://www.alfystudio.com/blog/91-joomla-3-error.html](http://www.alfystudio.com/blog/91-joomla-3-error.html)
   
   [http://vineetsaini.wordpress.com/2014/04/23/0-datetime__construct-datetime-construct-failed-to-parse-time-string-jerror-at-position-0-j-the-timezone-could-not-be-found-in-the-database/](http://vineetsaini.wordpress.com/2014/04/23/0-datetime__construct-datetime-construct-failed-to-parse-time-string-jerror-at-position-0-j-the-timezone-could-not-be-found-in-the-database/)
   [http://stackoverflow.com/questions/16632546/joomla-installing-new-language-datetime-construct-failed-to-parse-time-str](http://stackoverflow.com/questions/16632546/joomla-installing-new-language-datetime-construct-failed-to-parse-time-str)
 * mysql driver error?
    [http://www.jdownloads.com/forum/index.php?topic=6213.0](http://www.jdownloads.com/forum/index.php?topic=6213.0)
 * Actions for you:
    - Consider putting the shortcode version with listtype =4 at the bottom of the
      page just to see what happens.
    - Try debug why that page and not other pages with widget
    - See if links above comment on anything that migt relate to your site
    - When new version goes up, see if it traps the exception at all – let me know
    - .
 *  Thread Starter [ditler](https://wordpress.org/support/users/ditler/)
 * (@ditler)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/uncaught-exception-datetime_construct/#post-5048040)
 * This morning I tried to follow your suggestions from last time, but I cannot 
   access my page for now. Hoster is contacted.
 * Thanks so far!
 *  Thread Starter [ditler](https://wordpress.org/support/users/ditler/)
 * (@ditler)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/uncaught-exception-datetime_construct/#post-5048041)
 * Access again. Again, the problem only appeared when logged in, and only on the
   events page. However, I have corrected some code for widget logic now, so that
   the widget is not shown on events page (which is how it was supposed in the first
   place and worked in former days). So, for me the problem is solved, though I 
   do not know what caused it. It seems like the two instances (the main view is
   a lit-type 1, widget list-type 2 via pluggable-plugin) interfere with each other?
 * Thanks for your effort!
 *  Thread Starter [ditler](https://wordpress.org/support/users/ditler/)
 * (@ditler)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/uncaught-exception-datetime_construct/#post-5048042)
 * After all, it seems to have something to do with my pluggable plugin:
 *     ```
       <?php
       /*
       Plugin Name: amr_test_pluggable
       Author: anmari
       Author URI: http://anmari.com/
       Plugin URI: http://icalevents.com
       Version: 1.0
       Text Domain: amr_test_pluggable
       Domain Path:  /lang
   
       Description: test the amr-events and amr-ical-events-list pluggable functions.
       */
   
       function amr_list_events ($events,  $id, $class, $show_views=true) {
       global $amr_listtype;
       	$htmlo = '';
       	$no_events = count($events);
   
       if(!function_exists('spalte')) {
       function spalte ($von, $bis_exkl, $events, $doppelt, $monat=1) {
       	setlocale(LC_ALL, 'de_DE');
   
       	$spalteo = '<div>';
       	for ($i=$von; $i<$bis_exkl; $i++) {
       		$event = $events[$i];
       		// DESIGN ANFANG
       	if($event['URL'][0]!='') {
       			$spalteo .= '<a href="';
       			$spalteo .= $event['URL'][0];
       			$spalteo .= '#">';
       	}
       			$spalteo .= '<div class="eventbox" title="';
       			$spalteo .= $event['LOCATION'];
       			$spalteo .= '"><span class="eventbadge">';
       			$spalteo .= substr($monat,0,3);
       			$spalteo .= '<strong>';
       			$spalteo .= strftime('%d',$event['EventDate']->format('U'));
       			$spalteo .= '</strong></span><span class="eventtime">';
       			$spalteo .= strftime('%H:%M',$event['EventDate']->format('U'));
       			$spalteo .= '</span><span class="eventname">';
       			$spalteo .= $event['SUMMARY'][0];
       			$spalteo .= '</span></div>';
       	if($event['URL'][0]!=='')
       			$spalteo .= '</a>';
       			// DESIGN ENDE
       			if($doppelt) $i++;
       	}
       	$spalteo .= '</div>';
   
       	return($spalteo);
       }}
   
       // In die Monate aufteilen.
       $monatsname = array(1=>"Januar",
                       2=>"Februar",
                       3=>"März",
                       4=>"April",
                       5=>"Mai",
                       6=>"Juni",
                       7=>"Juli",
                       8=>"August",
                       9=>"September",
                       10=>"Oktober",
                       11=>"November",
                       12=>"Dezember");
       if(!function_exists('add_1_to')) {
       function  add_1_to ($monat) {
       	$ret = $monat+1;
       	if ($monat==12) $ret=1;
       	return $ret;
       }}
   
       $month[0]=(int)strftime('%m',$events[0]['EventDate']->format('U'));
       $starts[$month[0]]=0;
       for ($j=1;$j<$no_events;$j++) {
       	$month[$j] = (int)strftime('%m',$events[$j]['EventDate']->format('U'));
       	if ($month[$j] != $month[$j-1]) $starts[$month[$j]]=$j;
       }
       $starts[add_1_to($month[$no_events - 1])]=$no_events;
       // Hier entscheidet sich, welcher Listentyp gefragt ist.
   
       //  Zweispaltige Liste
       if ($amr_listtype=='1') {
       	foreach ($starts as $monat => $erstesElement) {
       		$htmlo .= '<h3></h3>';
       		$htmlo .= '<div style="float:left; width:49%;" class="eventm'.$monat.'">';
       		$htmlo .= spalte($erstesElement, $starts[add_1_to($monat)], $events, true, $monatsname[$monat]);
       		$htmlo .= '</div><div style="float:right; width:49%;" class="eventm'.$monat.'">';
       		$htmlo .= spalte($erstesElement+1, $starts[add_1_to($monat)], $events, true, $monatsname[$monat]);
       		$htmlo .= '</div>';
       	}
       }
   
       // Einspaltige kurze Liste
       elseif ($amr_listtype=='2') {
       	foreach ($starts as $monat => $erstesElement) {
       		$htmlo .= '<div class="eventm'.$monat.'">';
       		$htmlo .= spalte($erstesElement, $starts[add_1_to($monat)], $events, false, $monatsname[$monat]);
       		$htmlo .= '</div>';
       		}
       }
   
       // Widget
       elseif ($amr_listtype=='3')  {
       	$htmlo .= '<ul>';
       	foreach ($events as $i=>$event) {
       		$htmlo .= '<li style="white-space:nowrap;">'.strftime('%d.%m.',$event['EventDate']->format('U'));
       		$htmlo .= ' <strong>'.$event['SUMMARY'][0].'</strong></li>';
       	}
       	$htmlo .= '</ul>';
       }
       return($htmlo);
       }
       ```
   
 * I do not expect you to debug it for me; as said, for me the problem is pretty
   much solved now. This is just for your help, in case you are interested.
 *  [nerimizi](https://wordpress.org/support/users/nerimizi/)
 * (@nerimizi)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/uncaught-exception-datetime_construct/#post-5048099)
 * Hi,
    I’m experimenting those errors:
 * Unable to create DateTime object from jue 09 oct 2014 10:15:24 UTC
    DateTime::
   __construct(): Failed to parse time string (jue 09 oct 2014 10:15:24 UTC) at 
   position 0 (j): The timezone could not be found in the database
 * Unable to create DateTime object from jue 09 oct 2014 10:15:24 UTC
    DateTime::
   __construct(): Failed to parse time string (jue 09 oct 2014 10:15:24 UTC) at 
   position 0 (j): The timezone could not be found in the database
 * Warning: array_multisort(): Argument #1 is expected to be an array or a sort 
   flag in … amr-ical-calendar.php on line 702
 * The final results are:
    One calendar does not show the free busy, better say 
   does not show nothing
 * for the calendar with the “Unable to create …” nothing special in the UX (I only
   show the free busy information)
 *  Plugin Author [anmari](https://wordpress.org/support/users/anmari/)
 * (@anmari)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/uncaught-exception-datetime_construct/#post-5048100)
 * Hi nerimizi,please start your own topic, do not reuse a ‘resolved’ topic. The
   scenarios might be quite different. If you think they are the same you could 
   link to this one.
 * These sort of problems are usually caused by
    either 1) your own code introducing
   problems – eg passing a string like ‘jue 09 oct 2014 10:15:24 UTC’ to a date 
   time contruct statement – that will not work or 2) data in the ics file you are
   using and you have not provided that.
 * Please start a new topic and provide the ics url’s you are using. It might also
   be a good idea to say which list type and/or which fields you are trying to display.
   If you have written any custom code that may be affecting it, please eactivate
   that to debug whether that is causing the problem.

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Uncaught exception: DateTime::__construct()’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/amr-ical-events-list_f5f4f4.svg)
 * [amr ical events lists](https://wordpress.org/plugins/amr-ical-events-list/)
 * [Support Threads](https://wordpress.org/support/plugin/amr-ical-events-list/)
 * [Active Topics](https://wordpress.org/support/plugin/amr-ical-events-list/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/amr-ical-events-list/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/amr-ical-events-list/reviews/)

 * 10 replies
 * 3 participants
 * Last reply from: [anmari](https://wordpress.org/support/users/anmari/)
 * Last activity: [11 years, 8 months ago](https://wordpress.org/support/topic/uncaught-exception-datetime_construct/#post-5048100)
 * Status: resolved