adamjenkins / moodle-block_worldclock
A Moodle block that displays the current time in multiple timezones
Package info
github.com/adamjenkins/moodle-block_worldclock
Type:moodle-block
pkg:composer/adamjenkins/moodle-block_worldclock
Requires
- moodle/composer-installer: ^1.0
- moodle/moodle: ^5.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
A Moodle block that displays the current time in multiple timezones. It can be added to course pages, activities, and the Moodle dashboard.
Features
- Manual mode — pick any timezones from the full IANA timezone list to display, per block instance.
- Automatic mode — instead of a fixed list, the block displays every distinct timezone used by users enrolled in a course. On a course page this defaults to that course; anywhere else (e.g. the dashboard) you can explicitly choose the source course.
- Clocks update live in the browser (no page refresh) and correctly handle daylight saving time for named timezones.
- "Show date" can be restricted to "Only when different", so a timezone's date only appears when it differs from the viewing user's own date.
- Per-instance display options: 24-hour vs 12-hour format, seconds, date, a sun/moon day-night icon underneath each timezone's name (day/night boundary hours configurable site-wide), and a waking-hours background colour (pink overnight, yellow at the morning/evening transition, green during the day — boundary hours also configurable site-wide).
- Timezones are sorted chronologically by their current local date and time, as if every clock were read at the same instant — ascending or descending, per block instance. Clocks that currently share the same UTC offset are ordered alphabetically by name.
- Optionally show each timezone's current UTC offset (e.g. "UTC+9") next to its name.
- Multiple instances of the block can be added to the same page.
Installation
Requires Moodle 5.0 or later. Copy (or check out) this plugin into blocks/worldclock in your Moodle
installation, then visit Site administration > Notifications to complete
the install.
Configuration
Add the block to a course page or the dashboard, then use the block's Configure action to choose:
- Block title — optional override of the default title.
- Timezones to display — Selected timezones (manual list) or All timezones of users enrolled in a course (automatic).
- Course — only used in automatic mode; the course whose enrolled users' timezones should be shown. Leave blank to use the course the block is currently displayed on.
- Timezones — only used in manual mode; the fixed list of timezones to show.
- Sort order — Ascending or Descending chronological order.
- Show UTC offset, Use 24-hour time format, Show seconds, Show date (with an Only when different sub-setting), Show day/night icon, Colour background by time of day — display options.
In automatic mode, the viewing user must have the
moodle/course:viewparticipants capability in the source course or the
block will show nothing. Users who kept the default ("Server timezone")
are shown under the site's default timezone, and a forced site timezone
(forcetimezone) applies to every user, as elsewhere in Moodle.
Site administration settings
Under Site administration > Plugins > Blocks > World clock:
- The waking-hours background boundary hours (night/morning/day/evening start) apply to every block instance that has Colour background by time of day enabled.
- Icon day start / Icon night start control the boundary hours for the sun/moon day-night icon (defaults to 6am/6pm), for every block instance that has Show day/night icon enabled.
Continuous integration
A GitHub Actions workflow (.github/workflows/ci.yml) runs the
moodle-plugin-ci test suite
against Moodle 5.0, 5.1, and 5.2, using every PHP version each branch
actually supports (5.0/5.1: PHP 8.2-8.4; 5.2: PHP 8.3-8.4, since Moodle 5.2
raises its minimum PHP requirement to 8.3), crossed with both Postgres and
MariaDB; plus Moodle 5.3 (MOODLE_503_STABLE, PHP 8.3-8.4, PostgreSQL 17 and
MariaDB 11.4). The PHPUnit tests in
tests/ cover automatic mode (capability gate, server-default and forced
timezones, the zone cap), chronological sorting, UTC offset labels and the
rendered, escaped block output.
Privacy
The block only stores the configuration chosen by whoever added it (a
title, a mode, and a list of timezones or a course id). In automatic mode
it reads, but never stores, the timezone field of enrolled users purely to
render the block for the current request. See classes/privacy/provider.php.
Support
Report issues to the plugin maintainer.