I have a Django project with settings set to lang 'pl', in every template I use localized date format, for example:
{{ item.date|date:'D, d N H:i:s e' }}
result:
Wt, 13 Lis 2012 22:00:00
But in only one template I must use format for lang 'en':
Thu, 13 Nov 2012 22:00:00 GMT
How can I accomplish this?
The international standard recommends writing the date as year, then month, then the day: YYYY-MM-DD. So if both Australians and Americans used this, they would both write the date as 2019-02-03. Writing the date this way avoids confusion by placing the year first.
YYYY/MMM/DD. Four-digit year, separator, three-letter abbreviation of the month, separator, two-digit day (example: 2003/JUL/25) DD/MMM/YYYY. Two-digit day, separator, three-letter abbreviation of the month, separator, four-digit year (example: 25/JUL/2003)
The international format yyyy-mm-dd or yyyymmdd is also accepted, though this format is not commonly used. The formats d. 'month name' yyyy and in handwriting d/m-yy or d/m yyyy are also acceptable.)
The United States is one of the few countries that use “mm-dd-yyyy” as their date format–which is very very unique! The day is written first and the year last in most countries (dd-mm-yyyy) and some nations, such as Iran, Korea, and China, write the year first and the day last (yyyy-mm-dd).
This helps for me:
{% load i18n %}
{% language 'en' %}
{{ item.date|date:'D, d N H:i:s e' }}
{% endlanguage %}
For more details, see the Django online documentation.
This help for me, in that view where I use lang 'en' and load template:
from django.conf import settings
settings.LANGUAGE_CODE = 'en'
settings.USE_L10N = False
settings.USE_I18N = False
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With