Ced
Ced

Reputation: 711

Django equivalent of PHP's date

Does anybody know something similar to function date() from PHP in Django?

I'm starting to learn this nice framework, I'm very happy with it (at the momment) but i haven't found that function

Upvotes: 1

Views: 361

Answers (1)

Amal Murali
Amal Murali

Reputation: 76656

Yes.

date

Formats a date according to the given format.

Uses a similar format as PHP’s date() function (http://php.net/date) with some differences.

For example, you can do:

{{ value|date:"D d M Y" }}

If value is a datetime object (e.g., the result of datetime.datetime.now()), the output will be the string 'Jul 22 2013'.

Documentation:

Upvotes: 2

Related Questions