[Fixed]-Django date output format with 2 digits with leading zeros

1👍

You can use the strftime method:

from django.utils import timezone

date = timezone.now().date()
print date.strftime("%Y/%m/%d")
# Prints '2016/02/25'

You can check out this unofficial strftime reference for more details, or the official docs here.

👤Joseph

Leave a comment