Problems with Localtime

 

http://pytz.sourceforge.net/#problems-with-localtime

https://docs.djangoproject.com/en/2.2/topics/i18n/timezones/

 

The best and simplest solution is to stick with using UTC.

 

# https://docs.djangoproject.com/en/2.2/topics/i18n/timezones/

# Even if your website is available in only one time zone, it’s still good practice to store data in UTC in your database. The main reason is Daylight Saving Time (DST). Many countries have a system of DST, where clocks are moved forward in spring and backward in autumn. If you’re working in local time, you’re likely to encounter errors twice a year, when the transitions happen. (The pytz documentation discusses these issues in greater detail.) This probably doesn’t matter for your blog, but it’s a problem if you over-bill or under-bill your customers by one hour, twice a year, every year. The solution to this problem is to use UTC in the code and use local time only when interacting with end users.


# Time zone support is disabled by default. To enable it, set USE_TZ = True in your settings file. Time zone support uses pytz, which is installed when you install Django.

# https://docs.djangoproject.com/en/2.2/ref/settings/#std:setting-TIME_ZONE

# Django cannot reliably use alternate time zones in a Windows environment. If you’re running Django on Windows, TIME_ZONE must be set to match the system time zone.

# https://docs.djangoproject.com/en/2.2/topics/i18n/timezones/#time-zones-faq

TIME_ZONE = 'UTC'

https://docs.djangoproject.com/en/2.2/topics/i18n/timezones/#time-zones-faq 
 The solution to this problem is to use UTC in the code and use local time only when interacting with end users.     
http://pytz.sourceforge.net/#problems-with-localtime   
The best and simplest solution is to stick with using UTC.




(中国大陆、中国香港、中国澳门、中国台湾、蒙古国、新加坡、马来西亚、菲律宾、西澳大利亚州的时间与UTC的时差均为+8,也就是UTC+8。
) https://docs.djangoproject.com/en/2.2/topics/i18n/timezones/#time-zones-faq The solution to this problem is to use UTC in the code and use local time only when interacting with end users. http://pytz.sourceforge.net/#problems-with-localtime The best and simplest solution is to stick with using UTC.

 

posted @ 2019-10-08 14:40  papering  阅读(215)  评论(0编辑  收藏  举报