help to better help you:

Please: add always Joomla / JEM version and details to your posts, so we can try to reproduce your issue!

[Errors] - DateTime::__construct(): Failed to parse time string

[Errors] - DateTime::__construct(): Failed to parse time string

10 years 4 days ago - 10 years 4 days ago
#16211
just some info explaining why the message happens.
Code:
DateTime::__construct(): Failed to parse time string (Mon, 5. January 2015 04.08.AM) at position 27 (A): The timezone could not be found in the database

within the page we're using code like
Code:
$result['startDateTime'] = 'Mon, 5. January 2015 04.08.AM'; $start = new JDate($result['startDateTime']); $start_day = $start->format('m-d-Y');

JDate doesn't like the input other then the formats of php Date and in this case it doesn't like the text of 2 characters. When using UTC or something like that it it will recognize the timezone and will not trow in the error.

but to solve the above the AM should be stripped to something like this
Code:
$result['startDateTime'] = 'Mon, 5. January 2015 04.08'; $start = new JDate($result['startDateTime']); $start_day = $start->format('m-d-Y');


so when using the JDate function make sure that the input is correct as you will get an unfriendly error notice if it's used incorrectly.

Attachments:

Last edit: 10 years 4 days ago by Bluefox.

Please Log in or Create an account to join the conversation.

Re: [Errors] - DateTime::__construct(): Failed to parse time string

10 years 4 days ago - 10 years 4 days ago
#16216
to add:

JDate->format will at default set a timezone as the function includes this.
Code:
// If the returned time should not be local use GMT. if ($local == false) { parent::setTimezone(self::$gmt); } if ($local == false) { parent::setTimezone($this->tz); }

if you set the value to true it might solve the problem also
Code:
$value = new JDate($date); $value = $start->format('m-d-Y', true);
Last edit: 10 years 4 days ago by Bluefox.

Please Log in or Create an account to join the conversation.

Time to create page: 0.620 seconds