Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a localized date on Django template using a specific format?

I am having problems to get a localized date on Django templates.

I have this in my config file:

LOCALE_NAME ='es_VE'

LANGUAGE_CODE = 'es-ve'

TIME_ZONE = 'America/Caracas'

USE_I18N = True

USE_L10N = True

USE_TZ = True

The date I want to render is : mydate=2016-03-21 23:59:59.999999-04:30

This code {{mydate|date:"d/m/Y"}} shows "21/03/2016"

and this one {{mydate|localize}} shows "22 de Marzo de 2016 a las 04:29" (22/03/2016).

I want to get the result of the localize filter using the date's filter format.

Is there a way to achieve that?

like image 799
Mauricio Machuca Avatar asked Oct 30 '22 06:10

Mauricio Machuca


1 Answers

If I understand correctly, you want a localized custom date format. Django's documentation has something for you: Creating custom format files

like image 131
Clément Mangin Avatar answered Nov 09 '22 09:11

Clément Mangin