How to change date format?

Hello, how I can change date format?
Example Course starts - 1 oct. 2020 06:00 +06.
How to make Course starts - 1.10.2020
Thanks

1 Like

In /edx/app/edxapp/edx-platform/conf/locale/en/LC_MESSAGES/django.po change below lines to desired date format

LONG_DATE_FORMAT
DATE_TIME_FORMAT
SHORT_DATE_FORMAT
TIME_FORMAT

for example:

msgid "LONG_DATE_FORMAT"
msgstr "%A, %B %d %Y"

then run below lines to create .mo file from .po file

python manage.py lms compilemessages
python manage.py cms compilemessages

and finally restart lms and cms by this command:

sudo /edx/bin/supervisorctl restart lms
sudo /edx/bin/supervisorctl restart cms
1 Like

I tried this method but it didn’t work, I also tried other few ways:-
1.) [edx-platform/lms/djangoapps/courseware/date-summary.py]
Here, there is the “def date_format(self)” method where I changed the return type into ‘%d %b %Y’, but it did not work.

2.) [edx-platform/common/djangoapps/util/date_utils.py]
There are DEFAULT_SHORT_DATE_FORMAT = “%d %b, %Y”
DEFAULT_LONG_DATE_FORMAT = “%A, %d %B, %Y”
DEFAULT_DATE_TIME_FORMAT = “%d %b, %Y at %H:%M”
but these also didn’t worked.

3.) [edx-platform/lms/djangoapps/courseware/context_processor.py]
Here, I changed “user_language” from ‘pref_lang’ to ‘en-gb’/‘en-GB’, as it gives format of “dd/MM/yyyy” & in “def user_timezone_locale_prefs(request)” I made the same change of ‘user_language’ but didn’t achived any desired result at all.

4.) [edx-platform/lms/static/edx-ui-toolkit/src/js/utils/date-utils.js]
Here also I changed “var DEFAULT_LANG” to ‘en-gb’, but same its not making any change. Here there is also a portion :
var dateFormatEnum = Object.freeze({
shortDate: ‘ll’, // example: Jan 01, 2016
longDate: ‘LLLL’, // example: Friday, January 01, 2016
time: ‘LTS z’, // example: 15:30:32 UTC
defaultFormat: ‘ll HH[:]mm z’, // example: Jan 01, 2016 15:30 UTC
defaultWithParen: ‘ll HH[:]mm (z)’, // example: Jan 01, 2016 15:30 (UTC)
longDateTime: ‘dddd, ll HH[:]mm z’ // example: Friday, Jan 01, 2016 15:30 UTC
});
where I changed the “short date” format, which is passed as the type of format for date and in which I change it into ‘dd MMM YYYY’ but still no result is achieved.

I don’t know where the issue is prevailing, if you or anybody can sought-out it would be helpful.

1 Like