Sometimes you need to know the time somewhere else in the world. I find it useful to get my eggdrop to return the time of another timezone…

> .tz london
<Bot> HM2K, The time for the london timezone is Fri Feb 13 23:31:30 2009

However, much like my old weather.tcl, I realised that my worldtime.tcl had passed it’s sell by date and had now expired.

My old worldtime.tcl which was based on a script by Murf which used to gather it’s data had stopped working.

It would seem that had changed their markup which meant that it was no longer possible to parse the correct data from the HTML.

Never mind, I thought, there must be a better way, that doesn’t need to use a third party website, that won’t stop working.

After all operating systems have worldtime build in without using a website, so how do they do it?

So, I did some investigation…

I discovered that on Linux based systems (including FreeBSD) the time zone information was stored locally.


Using a bit of Google magic, I managed to locate a few pre-made procedures to help me read the time zone information.

  • load-timezones.tcl
    • get_tz_names
    • get_tz_rules

Using these functions I was able to find the right timezone and get the GMT offset which allowed me to work out the time in that timezone using the unix ticks.

At the moment, because it reads the time zone files that are only available on Linux based systems, it will not work on windrops.

However, what I may do next time is build a function that saves the timezone information into a database file which can be used on windows systems and will also give the Linux systems a cache file to make it respond quicker.

Update: I decided to stop using the tz database method and replace it with a Google lookup method, which is far more accurate and portable.

So now you’ll probably want to download it…

  • Download worldtime.tcl

Hope it works for you.


Note: If you find this useful, or have an issue with the script, please add a comment below. Thanks.

Related posts:

  1. Universal Currency Converter TCL for Eggdrop This is a currency converter written in TCL for Eggdrop,...
  2. weather.tcl Today, after I decided to hang out in #eggtcl on...
  3. Which is the best operating system? I’ve done my research and i’ve discovered there’s only 6...
  4. eTicket For the past few weeks I have been mostly working...
  5. PHPbase web framework What is the PHPbase web framework? PHPbase web framework (also...


  1. hm2k said,

    February 3, 2010 @ 10:05 am

    This script was updated as per this thread:

  2. murali said,

    March 5, 2010 @ 6:50 am

    i am able to user worldtime.tcl,

    Error Messge:

    [root@willet bkp_03-05-2010]# .tz worldtime.tcl
    -bash: .tz: command not found

  3. hm2k said,

    March 5, 2010 @ 1:28 pm

    This is an eggdrop tcl script, not a shell script.


RSS feed for comments on this post · TrackBack URL

Leave a Comment