Sorry if this was explained somewhere, but up to now - nothing found. So, I have an article published today, Aug.14th, at 11:11 local time. This means +3 hours from UTC. At MySQL table content I can see:

| created      | 2016-08-14 08:11:01 |

Here time zone has been already applied, time is stored in UTC, and this time in UTC is correct. (Or may be I am wrong here? I am using phpMyAdmin)

I want to print out the local time when the article was created - i.e. - 11:11 hrs.

Let's say that I can read this value and can apply time zone in opposite way and everything should be OK, except I want this conversation to be done in the future. The problem is that we have DST (Daylight Saving Time) and after some time I couldn't tell (at least easily) what was the real offset on Aug. 14th at 08:11 UTC - had we DST or not on that date? (Time offset could be +3 or +2 hrs from UTC depending on DST). Also I can not see in content table any record regarding stored time offset.

So, how to know/print out created time, exactly 11:11 hrs at place where article was created?

Suppose Joomla do that, right?

1 Answer 1


In database tables, dates are always in UTC.

Coordinated Universal Time (French: Temps universel coordonné), abbreviated as UTC, is the primary time standard by which the world regulates clocks and time. It is within about 1 second of mean solar time at 0° longitude;[1] it does not observe daylight saving time. It is one of several closely related successors to Greenwich Mean Time (GMT). For most purposes, UTC is considered interchangeable with GMT, but GMT is no longer precisely defined by the scientific community.

To display the date at page level, in Joomla general timezone or user time zone, you must convert it... and there are several ways to do it. A sample code:

    $timeZone = JFactory::getUser()->getParam('timezone');

    if (!$timeZone)
        $timeZone = JFactory::getConfig()->get('offset');

    $tz = DateTimeZone($timeZone);
    $date = JFactory::getDate($strdate);

    $userDate = $date->format(JText::_('A_DATE_FORMAT'), true);

Particularly, in com_content, you can find that the item created date is shown in this short way:

    echo JHtml::_('date', $item->created, JText::_('DATE_FORMAT_LC4'));
  • Joomla general timezone is saved in configuration.php
  • If a user has a specific timezone, you can find it in #__users table, params field as a JSON-encoded array.
  • So PHP is smart enough to know when DST was in force and to apply it accordingly. My code, which works somehow: $myDateTime = DateTime::createFromFormat('Y-m-d H:i:s', $v->publish_up, new DateTimeZone('UTC')); $myDateTime->setTimezone(new DateTimeZone('Europe/Sofia'));. The trick was to mention UTC when using createFromFormat. $v->publish_up is string taken from DB table.
    – pl71
    Aug 14, 2016 at 10:39
  • Yes, at the end, PHP DateTime and JDate work similarly
    – Anibal
    Aug 14, 2016 at 12:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.