The following code works and outputs the date for the different offsets:

echo 'Australia/Sydney' . JFactory::getDate('now', 'Australia/Sydney');
echo "<BR>";
echo 'UTC' . JFactory::getDate('now', 'UTC');
echo "<BR>";
echo 'Asia/Jakarta ' . JFactory::getDate('now', 'Asia/Jakarta');

But this code

echo 'Australia/Sydney' . JFactory::getDate('today', 'Australia/Sydney');
echo "<BR>";
echo 'UTC' . JFactory::getDate('today', 'UTC');
echo "<BR>";
echo 'Asia/Jakarta ' . JFactory::getDate('today', 'Asia/Jakarta');

All gives me the same result : 2015-04-29 00:00:00

How can I get Joomla to give me a date with the timezone offset that I select please?

  • 1
    This looks like a time zone issue.
    – user469
    Apr 28, 2015 at 1:00
  • 1
    The correct date in the database is the one that reflects the UTC date. That was the correct local date can be displayed anywhere. Meaning the date and time in UTC will be converted to NY time if your site user is in NY and to Singapore time if the user is in Singapore. Joomla provides you with a date class that manages this for you. What is the correct date and time right now? Everywhere has a different answer so it's best to store it as the time in Greenwich and then to display it as appropriate. As long as you say this is the day and time in Greenwich it IS correct.
    – Elin
    Apr 28, 2015 at 1:20
  • So how do I get the correct date?
    – Mat Kay
    Apr 28, 2015 at 2:29

2 Answers 2


OK so I believe this to be true :)

I was looking for a Joomla answer whereas I needed to use some Joomla and some php to get what I wanted.

JDate works off UTC timezone by default.

So you need to apply your server timezone offset (or user timezone offset) to the date first. That way,

$config = JFactory::getConfig();
$offset = $config->get('offset');
echo $offset;
echo "<br>";
$date = new JDate('today', $offset);
echo $date;
echo "<br>";
$date->setTimezone(new DateTimeZone('UTC'));
echo $date;
echo "<br>";

The output of the above for me was: Australia/Melbourne 2015-04-30 00:00:00 2015-04-29 14:00:00

and now I have the UTC offset of today for my server and can use it query data.


It could either be the system timezone: System => Global Configuration => Server => Location Settings

Or that particular user has a different timezone set in the user manager: Users => User Manager => Name => Basic Settings => Time Zone

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