(int) • day of Common Era (CE) • 1 = January 1, year 1 timestamp (float) • seconds since Epoch • 0 = Jan 1, 1970 at 00:00 string (str) • for humans • LOTS of formats!
◦ ¯\_(ツ)_/¯ • Most database, network, etc. libraries handle AWARE timestamps correctly Tip #1 - Always be AWARE Naive objects are easy to understand and to work with, at the cost of ignoring some aspects of reality. “ ” https://docs.python.org/3/library/datetime.html
rfc = parse("Sun, 05 Feb 2017 19:00:00 GMT") us = central.localize(parse("February 5, 2017 1:00 PM")) ctime = central.localize(parse("Sun Feb 5 13:00:00 2017")) military = parse("5 Feb 2017 1900Z") assert iso == rfc == us == ctime == military
UTC as soon as possible. B. Localize for user as late as possible. a. (And only if necessary.) C. Store/compare/manipulate times as UTC throughout system.
A. All timestamps are generated in the same time zone. B. Your users are in the same time zone. C. You don't care about daylight saving time. D. There's never a chance A, B, or C will change.
A. All timestamps are generated in the same time zone. B. Your users are in the same time zone. C. You don't care about daylight saving time. D. There's never a chance A-C will change.
about the time zone where the timestamp was created. PyTN 2017 Keynote: 2017-02-04 09:00:00-06:00 PyCon 2017 Keynote: 2017-05-19 09:00:00-07:00 PyOhio 2017 Keynote: 2017-07-29 09:00:00-04:00
reference to the time zone where the timestamp was created. PyTN 2017 Keynote: 2017-02-04 09:00:00-06:00 PyCon 2017 Keynote: 2017-05-19 09:00:00-07:00 PyOhio 2017 Keynote: 2017-07-29 09:00:00-04:00 PREFERRED: Keep separate time zone data (e.g. django-timezone-field) OK
BY 2.0], via Wikimedia Commons. • Watch: https://commons.wikimedia.org/wiki/File:Naturejournal36londuoft_0523.jpg. By "Nature" ("Nature" journal, September 22, 1887, pp. 485) [Public domain], via Wikimedia Commons. • Train & Clock: https://pixabay.com/en/old-vintage-retro-locomotive-train-952238/. By ArtsyBee [CC0]. • Time Zone Map: https://commons.wikimedia.org/wiki/File:Standard_World_Time_Zones.png. By TimeZonesBoy (Own work) [CC BY-SA 4.0], via Wikimedia Commons. • Atomic Clock: https://commons.wikimedia.org/wiki/File:Atomic_Clock-Louis_Essen.jpg. By National Physical Laboratory [Public domain], via Wikimedia Commons. • Date Time Formats: https://xkcd.com/1179/. By Randall Munroe [CC BY-NC 2.5]. • Iceberg: https://commons.wikimedia.org/wiki/File:Wikisource-logo.svg. By Nicholas Moreau [CC BY-SA 3.0], via Wikimedia Commons.