问题
I'm unable to figure out that how to format present time in django views. I just want to show year-month-date or (y,m,d) .Can you guys tell me how to do this ?
Right now i'm trying in a following way.
from django.utils import timezone
print('date :',timezone.now())
and it returns :
date : 2020-12-31 18:34:29.309006+00:00
Desire output is : date : 2020-12-31
回答1:
from datetime import datetime
my_date = datetime.now().strftime("%Y-%m-%d")
来源:https://stackoverflow.com/questions/65524569/how-to-format-current-time-in-django-views