Django and dates in UTC -
i use django use_tz
set true
. set time_zone
. thing datetimes stored in db in utc (-2 hours timezone). when print datetime template it's still in utc.
how automaticaly tell django print datetimes in local timezone (which should default behavior).
i use mysql , datetime saved 2016-09-20 22:00:00
2016-09-21 00:00:00
in local timezone.
thanks.
you can local time using arrow , datetime packages. , can use arrow convert date & time in required formats. install arrow in virtualenv using pip command.
import arrow import datetime today = arrow.utcnow().to('asia/calcutta').format('yyyy-mm-dd hh:mm:ss') '2016-09-13 15:57:38'
visit our blog, know more arrow , installation procedure https://micropyramid.com/blog/python-arrow-to-show-human-friendly-time/
Comments
Post a Comment