datetimefield 에러 해결 - 1

hyuckhoon.ko·2021년 6월 24일
0

What I learned in first year

목록 보기
86/146
Consignment.objects.filter(is_pickup=True).last().pickup_date

결과

datetime.datetime(2021, 2, 28, 15, 0, tzinfo=<UTC>)


pickup_date_datetime = data["pickup_date"]
seoul_timezone = pytz.timezone("Asia/Seoul")
seoul_datetime = pickup_date_datetime.replace(tzinfo=pytz.utc)
seoul_datetime = seoul_datetime.astimezone(seoul_timezone)
pickup_date = seoul_datetime.strftime("%Y년 %m월 %d일(%a)")

참고자료: https://spoqa.github.io/2019/02/15/python-timezone.html

https://www.kite.com/python/answers/how-to-convert-a-utc-datetime-to-a-local-datetime-in-python

0개의 댓글