Sokunthaneth Chhoy
Sokunthaneth Chhoy

Reputation: 126

Bootstrap: convert date format- mm/dd/yyyy

I am writing a Django web application and using Material Kit(Bootstrap) for front end. I want to display the date on the html in the format of mm/dd/yyyy.

e.g.

06/27/2018

I view date in database table, and it is already in the format of mm/dd/yyyy.

I have no idea why it's display in the .html in the format of

June,28 2018

I think it's because of Material Kit, but I don't have idea any how to convert or override the function. Please help!

Upvotes: 1

Views: 981

Answers (1)

Bijoy
Bijoy

Reputation: 1131

If you have set USE_TZ = True in settings.py then date and time information stored in database are in UTC, and transformed to the local date or time in templates w.r.t TIME_ZONE value given in settings.py

And also you can change the default date format, by defining DATE_FORMAT in settings.py, its default value is in 'N j, Y' format. So you can try changing that to DATE_FORMAT = 'm/d/Y'

OR

If you want the date value to be in specific format in templates you can do

{{ date_value|date:'m/d/Y' }}

Upvotes: 1

Related Questions