Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need to make your datetime objects timezone aware. from the <a href="http://docs.python.org/library/datetime.html#module-datetime" rel="noreferrer">datetime docs</a>:</p> <blockquote> <p>There are two kinds of date and time objects: “naive” and “aware”. This distinction refers to whether the object has any notion of time zone, daylight saving time, or other kind of algorithmic or political time adjustment. Whether a naive datetime object represents Coordinated Universal Time (UTC), local time, or time in some other timezone is purely up to the program, just like it’s up to the program whether a particular number represents metres, miles, or mass. Naive datetime objects are easy to understand and to work with, at the cost of ignoring some aspects of reality.</p> </blockquote> <p>When you have an aware datetime object, you can use isoformat() and get the output you need.</p> <p>To make your datetime objects aware, you'll need to <a href="http://docs.python.org/library/datetime.html#datetime.datetime.strftime" rel="noreferrer">subclass tzinfo, like the second example in here</a>, or simpler - use a package that does it for you, like <a href="http://pytz.sourceforge.net/" rel="noreferrer">pytz</a> or <a href="http://labix.org/python-dateutil" rel="noreferrer">python-dateutil</a></p> <p>Using pytz, this would look like:</p> <pre><code>import datetime, pytz datetime.datetime.now(pytz.timezone('US/Central')).isoformat() </code></pre> <p>You can also control the output format, if you use strftime with the <a href="http://docs.python.org/library/datetime.html#strftime-and-strptime-behavior" rel="noreferrer">'%z' format directive</a> like</p> <pre><code>datetime.datetime.now(pytz.timezone('US/Central')).strftime('%Y-%m-%dT%H:%M:%S.%f%z') </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload