Show live session times in each learner's time zone in Moodle

A date typed into a Moodle page is the same text for everyone, in every country. Our free filter_localtime plugin shows it in each learner's own time zone. How it works.

Drawing of three wall clocks in a row, the middle one painted blue, above a single calendar page.

Short answer: Moodle shows its own dates (deadlines, calendar events) in each user’s time zone, but a time you type into a page, label or forum post is plain text. “Live session at 14:00” means a different hour in Paris, Lagos and Tokyo. Our free filter, filter_localtime, fixes that with one tag.

This is the second plugin in our series: one plugin for each Moodle plugin type, each one teaching our AI plugin builder, DevLMS Studio, how that type works.

How to use it

Type the time once, with the zone you mean:

Live session {localtime 2026-12-01 14:00 Europe/Paris}
  • A learner whose Moodle profile is set to Tokyo sees “Tuesday, 1 December 2026, 10:00 PM”. One in Paris sees 2:00 PM.
  • Leave out the zone and the time is read in the site’s default time zone.
  • A tag that does not parse (a wrong date, an unknown zone) stays exactly as typed, so the author notices.
  • It works anywhere Moodle formats text: pages, labels, forum posts, assignment and quiz descriptions.

It supports Moodle 4.5 LTS to 5.3, stores no data, and is GPL. The code is on GitHub. After installing, turn it on in Site administration > Plugins > Filters > Manage filters. Filters are off when installed.

How a Moodle filter works

A filter gets a piece of HTML just before Moodle shows it and returns new HTML. What we checked in Moodle 5.3’s code:

  1. Since Moodle 4.5, a filter is one class: classes/text_filter.php, extending \core_filters\text_filter, with a filter($text) method. The old filter.php file is now only a deprecated stub in core plugins.
  2. Filters run on almost every string on every page, so the first line should return the text untouched when the tag is not there.
  3. Your filter runs after Moodle has cleaned the HTML. Anything you insert is not cleaned again, so every value has to be escaped by your code.
  4. Nothing caches the filtered text per site, so output that depends on who is looking (their time zone, their name) is safe.

We tested it with PHPUnit (Paris to Tokyo, site zone to New York, bad dates and zones, text without the tag) and a Behat run where a learner set to Tokyo opens a page and sees Tokyo time.

What Studio learned

The guide for filters is now part of DevLMS Studio’s builder. It gets it the moment it starts a filter, so it writes the 4.5 class form, returns early, and escapes what it inserts.

Need a filter of your own, like turning course codes into links or hiding text until a date? Describe it in DevLMS Studio and watch it built and tested in a real Moodle.

Need a plugin like this for your own Moodle?

Describe it in DevLMS Studio and watch it built and tested in a real Moodle, or ask our team for a fixed price.

Open DevLMS Studio