Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod
- » MetaMod General Support
- » Timezone dependent modules
Timezone dependent modules
Timezone dependent modules
Hello!
My current task is to establish separate showing of two different mod_mainmenu modules dependent of visitor's timezone. In example, I have one mod_mainmenu for Irkutsk (UTC+9, ID 229) and one for Toronto (UTC-5, ID 230) and trying to set the 2 Metamod modules to show this modules separately.
I'm trying to use this constructions such as:
In first module:
if ( $timezone == "UTC+9" ) return 229;
In second module:
if ( $timezone == "UTC-5" ) return 230;
, but when I check my website, I see strange things. It shows Toronto module for Irkutsk and when I try to load website via US web proxy (linear.ws), it shows Toronto too.
Here is debug output:
From Irkutsk:
As you can see, the $timezone output is always UTC-9 (????). OK, maybe my browser transferring my real timezone through proxy, but why it shows UTC-9 for Irkutsk, when it must show UTC+9 ?
OK, maybe I was totally wrong thinking that Metamod supports timezone-dependent modules or did some syntax error... Please help me

-Joomla 1.5.26 latest
-Metamod 2.12 latest
-GeoIP Country (free or commercial) is enabled, .dat files is uploaded to the proper location
-Caching is disabled for metamod modules
-Metamod's Timezone setting is set to Joomla Default
Re: Timezone dependent modules
Hi pavelcarcass,
the answer is fortunately easy but unfortunately bad news. The $timezone variable does not relate to the client. It only relates to the setup of the MetaMod, to what the timezone drop down is set to.
A web client does not normally send information about which time zone it is in, to the web server, as part of its web request.
The time zone may be able to be deduced if you use the GeoLiteCIty database, and want to work with the $geoip->longitude variable. It's not perfect, but I imagine that the longitude and the time zone generally are related. But it won't be perfect, and I don't know if every IP address will necessarily have a longitude associated with it.
From this page:
http://stackoverflow.com/questions/5584 … like-geona
I see this, for rough calculations:
"However, some very rough approximation can be calculated: 1 hour difference corresponds to 15 degrees longitude (360 / 24)."
Does that help?
Cheers,
Stephen
Re: Timezone dependent modules
Hello metamodguy!
Thank you for your answer, now I have some food for thought.
I'd like to explain in general, what I have to do: the joomla-based website, which is authomatically determinate a content (especially, the modules) depending of visitor's region. And the more I investigate, the more I think that Joomla isn't good for such task
The best thing for me is $geoip->city (with GeoLite City database) , but it's WAY too inaccurate.
By the way, does the "GeoCity (commercial)" have any benefits in comparison with free GeoLite City?
Re: Timezone dependent modules
You can have a look at the comparisons with the different databases at www.maxmind.com. The commercial database is a little more accurate, but not that much (last time I looked). And it varies enormously between countries.
If the issue is about determining location, then it's really not Joomla that's the problem. The question is really about which underlying technologies you have available for determining location. You could look for alternative GeoIP databases, or alternatively look at JavaScript methods for requesting location data, which will often be highly accurate if the user is on a GPS-equipped mobile and gives you permission.
Hope that helps,
Stephen
- Index
- » MetaMod
- » MetaMod General Support
- » Timezone dependent modules
Board Info
- Board Stats:
- Total Topics:
- 1689
- Total Polls:
- 6
- Total Posts:
- 5942
- Total Posts Today:
- 1
- User Info:
- Total Users:
- 7624
- Newest User:
- borger3298
- Members Online:
- 0
- Guests Online:
- 133
- Online:
- There are no members online
Forum Legend:
Topic
New
Locked
Sticky
Active
New/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky/Active/Locked