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()
[Errors] - DateTime::__construct()
10 years 4 days ago
This error can happen if we're using a language like Chinese.
Within the page we have code like this
when looking at the output we see that the values do have weird characters in it and can imagine why Joomla is trowing the error. The thing here is that JDate->format is localizing the output at default (month+day but no AM-PM). As we're passing the translated strings to the JDate function it will protest.
so to avoid the problem we've to make sure that untranslated strings will be passed into the second JDate function
Code:
DateTime::__construct()
Within the page we have code like this
Code:
$datetimeStart = new JDate($row->dates.' '.$row->times);
$otimeStart = $datetimeStart->format('H:i');
$odateStart = $datetimeStart->format($dateFormat);
.........................
$result = array();
$result['dateStart'] = $odateStart;
.............
$start = new JDate($odateStart);
$start_day = $start->format('m-d-Y');
$end = new JDate($odateEnd);
$end_day = $end->format('m-d-Y');
..............
return $result;
when looking at the output we see that the values do have weird characters in it and can imagine why Joomla is trowing the error. The thing here is that JDate->format is localizing the output at default (month+day but no AM-PM). As we're passing the translated strings to the JDate function it will protest.
so to avoid the problem we've to make sure that untranslated strings will be passed into the second JDate function
Please Log in or Create an account to join the conversation.
Re: [Errors] - DateTime::__construct()
10 years 4 days ago
Generally you should prevent formatted strings as much as possible because they require at least very time intensive conversions.
Instead of
it's better to use
Instead of
Code:
$datetimeStart = new JDate($row->dates.' '.$row->times);
$odateStart = $datetimeStart->format($dateFormat);
$start = new JDate($odateStart);
Code:
$datetimeStart = new JDate($row->dates.' '.$row->times);
$start = clone $datetimeStart;
The following user(s) said Thank You: Bluefox
Please Log in or Create an account to join the conversation.
Time to create page: 0.425 seconds