I've been struggling to get the correct date and time in a module.
I set global config to London (i.e. GMT which is currently 1 hour ahead of UTC)
I set the date in my component to
2020-05-10 12:50:00 (calendar select box)
and this seems to work. It's stored as
2020-05-10 11:50:00 in the database - so the timezone is being correctly accounted for.
I then go to retrieve it in my module adjusting for the time zone
$config = JFactory::getConfig(); $debug = $config->get('offset'); $myDateString = $itemStartDate; //the date stored in the db 2020-05-10 11:50:00 $date = new JDate($myDateString); $date->setTimezone($debug); echo "database date is ".$itemStartDate." and calculated date is ".$date->format(JText::_('DATE_FORMAT_FILTER_DATETIME'));
The date shown by the echo statement is just the date from the database - it doesn't account for the 1 hour time difference.
Am I doing something wrong?
I looked in config and there is offset and offset_user - offset is set to Europe/London and offset_user to UTC (although when I manually change it to Europe/London is makes no difference)