H
H
hardwellZero2015-05-01 10:02:00
Flask
hardwellZero, 2015-05-01 10:02:00

How to make your own date format?

Good afternoon.
I have a small Flask project.
In one of the database tables - sqlite3 there is a field of type Date.
By default, it only accepts dates of the form: "2010-12-30 12:10:04.000100"
But I would like it to be in a format more familiar to the average user "12-31-2015 15:58" (%d %m %Y %H %M)
How can this be implemented?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
hardwellZero, 2015-05-01
@hardwellZero

Carelessness.
I decided:
{{date.date.strftime('%d-%m-%Y %H:%M')}}

A
Alexander, 2015-05-01
@NeiroNx

Well, it's better to force all date fields to be converted to a string with the desired format using the strftime() function
datetime.now().strftime("%d.%m.%Y %H:%M:%S")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question