So I have this component (built with JCB) where I need to display a saved datetime from the db (without seconds, but that's not my focus right now). Because of some limitations, I cannot simply declare use
statements at the top of the model.
I'm now at the point that I called the JDate
like so:
$date = new Joomla\CMS\Date\Date($item->kickoff);
$datenow = new JDate($item->kickoff);
$dateHtml = '';
echo '<pre>' . var_export($item->kickoff,true) . '</pre>';
echo '<pre>' . var_export($date,true) . '</pre>';
$item->calculated_name = $dateHtml;
The export gives me:
'2020-07-30 12:00:00'
Joomla\CMS\Date\Date::__set_state(array(
'tz' => DateTimeZone::__set_state(array(
'timezone_type' => 2,
'timezone' => 'GMT',
)),
'date' => '2020-07-30 12:00:00.000000',
'timezone_type' => 2,
'timezone' => 'GMT',
))
I should now be able to use the information from the export, but I cannot. I cannot access $date->date
or $date->get('date')
because it's in set state.
I'm not able to use HtmlHelper
because I cannot use it like so:
$dateHtml = new Joomla\CMS\HTML\HTMLHelper($date, Text::_('DATE_FORMAT_FILTER_DATETIME'));
My goal: Access the kickoff date calculated with the offset (Joomla installation timezone)
Any hints?