LeoClock
What it is
LeoClock is a clean and simple yet very functional clock available as Joomla module and standalone script.
Unlike most Joomla module clocks I could find this does not use Javascript to get the time but instead does so through PHP which means mainly two things. First, everyone visiting the page will get the same time even if the clock on their computer is wrong as it uses the Server clock. Second, it has access to the handy timezone options in PHP, e.g "Europe/London" and "America/New_York".
The settings for the module are the following:
- PHP Timezone.
- Whether or not timezone should be showed below the clock.
- Lets you choose if the displayed timezone should be complete with continent or just city. Either way it will format the original PHP timezone for nicer display. In addition you can choose to display a custom string in place of the standard timezones (added in version 1.2).
- Europe/London shows as "Europe, London" if full and "London" if city.
- America/New_York shows as "America, New York" if full and "New York" if city.
- America/Indiana/Knox shows as "America, Indiana, Knox" if full and "Knox" if city.
- Indian/Chagos shows as "Indian Ocean, Chagos" if full and "Chagos" if city.
- Whether or not seconds should be displayed.
- Time format, 24 or 12h.
- Whether or not the current date should be displayed and if it it should, in what format. (Added in version 1.2.)
The module supports multiple instances running on the same page, just make sure you give them different names.
The module is available in Joomla 1.5 and Joomla 2.5 versions. The 2.5 version has been tested with Joomla 2.5 as well as 3.0 but it should work on any version above 1.6.
Why I created it
I wanted a clock for my guild's website that showed everyone the same time, I wanted it to be for a specific timezone, and I wanted the clock to update in realtime. PHP is of course only run when the page loads so can't provide a live clock and Javascript relies on the clock in the visitor's computer and has no function to simply pick a timezone. I combined the best of both.
The clock started out like a single .php file with all the code which I hosted on my own server and put on the guild site using an iframe. I later decided to convert it into a proper Joomla module so it could run directly on the site and share it.
Eventually I moved the guild site away from Joomla and thus converted the Joomla module back to a standalone script which can now be found here as well for those who might want a great clock for their non-Joomla site.
Future plans
I consider LeoClock feature complete, it does more than I ever needed of it and I have no plans for additional functionality.
I do want to rewrite it at some point, using things I've learnt since and possibly clean up the code. Could give me a freash start with better version numbering too.
If you have suggestions, feel free to send them my way, I might do something with it.
Should any bugs show themselves LeoClock will of course receive bugfixes. The exception to this is the Joomla 1.5 version which will not be updated beyond 1.2.5.
Demo
Below are three instances of LeoClock with varying configurations.
Version History
- Version 1.3.1 - May 23 2014
- Small bug fix for joomla module.
- Version 1.3.0 - May 22 2014
- In 12h format the clock now reads 12 at midnight, rather than 0 as before.
- Added new style options for the Joomla Module (see the advanced settings tab of the module):
- You can now choose between a the old vertical layout and a new horizontal layout.
- There are size/styling options for the time, date and timezone. Including the option to not add any CSS at all, giving you full control
- The time, date and timezone are all in their own div (or span for horizontal layout) and have their own classes for easy CSS selection, LeoClock_time, LeoClock_date and LeoClock_timezone.
- Standalone code got some changes as well:
- The make_leoclock() function can now be called without any parameters at all in which case a set of default values will be used.
- Parameters are now passed to make_leoclock() using an associative array instead of plain old parameters. This to allow you to more easily just set one or two parameters and have the rest use default values.
- Version 1.2.5 - April 19 2014
- Added the option to only remove the leading zero on hours.
- Version 1.2.5a - January 10 2014
- Fixed critical problem in handling of leading zeros.
- Version 1.2.5 - January 02 2014
- Fixed the spelling error. Okt -> Oct
- Fixed missing leading zero for day.
- Standalone version released.
- Version 1.2.4 - February 23 2013
- Made the use of leading zeros optional. The option applies to the clock in both formats and the date where applicable.
- Version 1.2.3a - February 21 2013
- Hotfix - Small bug fix.
- Version 1.2.3 - February 21 2013
- Fixed a bug where the clock if set to 12h format would always show AM even if the current time was actually PM.
- Added two additional date formats, 'MM/DD/YYYY' and 'Jan 16, 2013'.
- Version 1.2.2 - February 01 2013
- Add the option to specify your own string to be displayed in place of the Timezone.
- Will now correct for missed seconds due to various forms of Javascript slowdowns/suspensions.
- Version 1.2 - January 16 2013
- Added date output with seven different formats.
- Version 1.1.1 - January 10 2013 (only applies to the version for 2.5 and up)
- Fixed a small issue which prevented Joomla 3.0 compatibility
- Version 1.1 - October 31 2012
- First public release
License
Download
If you're updating your Joomla module install you might need to open the settings page for any existing instances of the module and reapply the settings (no need to change anything) for the clock to work.