Is there a filter for displaying dates and time in a timezone-sensitive manner?

Is there a filter for displaying dates and time in a timezone-sensitive manner?

by Penguin Razzmatazz -
Number of replies: 7
Discord, a popular instant messaging social platform, has a feature called "timestamps" which makes it possible to write dates and times in a way that will display differently for different Discord users according to their local time zone. Timestamps are useful in international environments to discuss or make announcements about the date and time of future events.

For instance, a timestamps that displays as "June 1, 2022 08:00 AM" for a person accessing Discord from California, displays as "June 1, 2022 11:00 AM" for a person in New York, as "June 1, 2022 4:00 PM" for a person in the UK, and as "June 2, 2022 1 AM" for a person in Australia.

A Discord timestamp looks like this: <t:1654095600:f>. If this piece of code is entered into a Discord message when the message is in edit mode, it will be automatically converted to a timezone-sensitive human readable form when the message is in display mode. This is similar to the way filters work in Moodle, for instance to convert a sequence of characters to an emoticon.

Is there a Moodle filter with a similar functionality to Discord timestamps? If not, is there some other way to accomplish this functionality in Moodle?
Average of ratings: -
In reply to Penguin Razzmatazz

Re: Is there a filter for displaying dates and time in a timezone-sensitive manner?

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators
If the user sets their timezone in their profile (as I presume you have done here?) then Moodle automatically displays everything in their local timezone. For example in this forum it said you posted your question at 4.40 am (I am in the UK Were you really up that early on a Saturday or are you in a country several hours later than GMT?). So if I set an assignment to be due at 9 am on Monday then it will show to an Australian to be due some time Monday afternoon and to a North American at some time Sunday night - does that help? It won't automatically change any time you write - so if I write 9 am you will still see 9 am - but it will display calendar deadlines etc in the correct timezone for each person IF they have set their time in their profile.
Average of ratings: Useful (1)
In reply to Mary Cooch

Re: Is there a filter for displaying dates and time in a timezone-sensitive manner?

by Penguin Razzmatazz -
Thanks. I did post at an ungodly hour - my sleep pattern is woefully irregular - though not as blasphemous as 4:40 AM. As a poet once wrote: "I have measured out my life with coffee spoons."
In reply to Penguin Razzmatazz

Re: Is there a filter for displaying dates and time in a timezone-sensitive manner?

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators

As Mary has explained, Moodle behaves in the friendliest possible manner: It converts timestamps to the user's timezone. Only thing, it won't tell you or indicate in any way that when you see "Saturday, 28 May 2022, 7:12 AM" (notice the missing timezone) it means your timezone. This was at the root of many, some surreal, discussions here. See User Logs - Timezone Presented or Question about timezone or Request to developers: Please display clock time always with its time zone or Clock in moodle.org is AWST (without saying so)?.

P.S. I guess the Penguin in your pseudonym is supposed to mean that your are a Linux fan? Still, I appreciate talking to real persons.


In reply to Visvanath Ratnaweera

Re: Is there a filter for displaying dates and time in a timezone-sensitive manner?

by Penguin Razzmatazz -
Thanks. Actually, the way I understand Mary's reply, Moodle does not behave in the friendliest possible way, since it does not have a filter similar to Discord's timestamps that enables the users to type in a date in ATTO, say, and this date would be automatically displayed in the local timezone of the respective viewers.

If Moodle did have a filter like this, then the suggestion you made in this other thread to use the Choice activity for scheduling a group meeting between people dispersed in multiple time zones would be a little more viable as an alternative to Doodle.

I understand the confusion that may result from displaying a date without time zone information, but there are ways to resolve this without giving up the convenience of an automatically time zone adjusted date. For instance, if every time zone adjusted date would be accompanied by a little visual indicator, the way links that open in a different tab are often accompanied by the icon The standard "open in a new tab" icon.. Such a visual indicator could even be the literal time zone abbreviation (e.g. "IST"), but it would be automatically injected by a filter and adjusted to the viewer's local timezone, rather than set in immutable form by the writer of the date. A Discord timestamp is distinguished from regular text by a darker background color and by a tool tip that pops up when the cursor hovers over it.

By the way, writing out a time zone abbreviation is not a panacea for time zone confusion: "IST" is both "India Standard Time" (UTC+5:30) as well as "Israel Standard Time" (UTC+2:00).
Average of ratings: Useful (1)
In reply to Penguin Razzmatazz

Re: Is there a filter for displaying dates and time in a timezone-sensitive manner?

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
It's a good point - we see people getting caught by this all the time. They set the start time of an Assignment at (say) 09:00 - this works fine in other timezones. They then write in a forum "Assignment opens at 9am" which doesn't.

I never thought of creating a filter to do that. Could be an interesting project.
Average of ratings: Useful (2)
In reply to Howard Miller

Re: Is there a filter for displaying dates and time in a timezone-sensitive manner?

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
I don't have time (pun intended) to work on it myself, but I suspect this could be easily done with a Generico filter.
In reply to AL Rachels

Re: Is there a filter for displaying dates and time in a timezone-sensitive manner?

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I almost wrote.... "but someone will be along in a minute telling you it can be done with the Generico filter". The Generico filter is completely beyond my comprehension but your milage may vary big grin