user13955
user13955

Reputation: 870

Joomla 3.1: how to get timezone offset?

Does anybody know how to get the system timezone offset in Joomla 3.1? I've tried the following:

    return JFactory::getConfig()->getValue('offset');

but this results in the following error:

    Fatal error: Call to undefined method JRegistry::getValue()

Thanks for any info pointing me in the right direction ....

Upvotes: 1

Views: 3822

Answers (2)

MJH
MJH

Reputation: 633

Try:

$timezone = new DateTimeZone(JFactory::getConfig()->get('offset'));
$offset   = $timezone->getOffset(new DateTime)/3600;

Upvotes: 0

mozami
mozami

Reputation: 7521

Try this:

$config = JFactory::getConfig();
$offset = $config->get('offset');

Upvotes: 3

Related Questions