How can an admin set the datetime format?

(Michael Downey) #1

How can an admin specify the datetime format used by their Discourse installation? We’d like to standardize on ISO 8601 across all our webapps.

(Kane York) #2

You can change the client-side ones with code in </head>:

I18n.translations.en.js.dates.time = "HH:mm"
I18n.translations.en.js.dates.long_with_year = "DD MMM YYYY HH:mm:ss"
I18n.translations.en.js.dates.long_date_with_year = "DD MMM YYYY HH:mm:ss"
I18n.translations.en.js.dates.long_no_year_no_time = "DD MMM YYYY"
I18n.translations.en.js.dates.long_with_year_no_time = "DD MMM YYYY"

Build the rest using Moment.js | Docs

(Michael Downey) #3

Thanks, but even when adding those changes you provided, I don’t see the new formats showing up anywhere in a new browser session. Looked on badge listings, the full date-time in a post’s “share” box, hover/tooltips, etc.

Is there anything to do other than adding them to the proper place in admin customizations?

(Kane York) #4

You need to do all of the formats. Put I18n.translations.en.js.dates in your browser console and expand the object to see the rest.


There really are a lot of formats involved. Even pulling out a list of them from that object via the browser console is a daunting task.

riking, is it possible to give a simple guide to what’s involved with the momentjs stuff? Is there a path through this that someone who is not a javascript developer could follow?