<li><strong>To extract time use <codeclass="python hljs"><spanclass="hljs-string">'<DTn>.time()'</span></code>, <codeclass="python hljs"><spanclass="hljs-string">'<DTa>.time()'</span></code> or <codeclass="python hljs"><spanclass="hljs-string">'<DTa>.timetz()'</span></code>.</strong></li>
</ul>
<div><h3id="timezone">Timezone</h3><pre><codeclass="python language-python hljs"><tzinfo> = UTC <spanclass="hljs-comment"># UTC timezone. London without DST.</span>
<div><h3id="timezone">Timezone</h3><pre><codeclass="python language-python apache hljs"><tzinfo> = UTC <spanclass="hljs-comment"># UTC timezone. London without DST.</span>
<tzinfo> = tzlocal() <spanclass="hljs-comment"># Local timezone. Also gettz().</span>
<tzinfo> = gettz(<spanclass="hljs-string">'<Cont.>/<City>'</span>) <spanclass="hljs-comment"># 'Continent/City_Name' timezone or None.</span>
<DTa> = <DT>.astimezone(<tzinfo>) <spanclass="hljs-comment"># Datetime, converted to passed timezone.</span>
<Ta/DTa> = <T/DT>.replace(tzinfo=<tzinfo>) <spanclass="hljs-comment"># Unconverted object with new timezone.</span>
<Ta/DTa> = <T/DT>.replace(tzinfo=<tzinfo>) <spanclass="hljs-comment"># Unconverted object with new timezone.</span>
</code></pre>
<div><h3id="encode">Encode</h3><pre><codeclass="python language-python apache hljs"><D/T/DT> = D/T/DT.fromisoformat(<spanclass="hljs-string">'<iso>'</span>) <spanclass="hljs-comment"># Object from ISO string. Raises ValueError.</span>
<DT> = DT.strptime(<str>, <spanclass="hljs-string">'<format>'</span>) <spanclass="hljs-comment"># Datetime from str, according to format.</span>
<D/DTn> = D/DT.fromordinal(<int>) <spanclass="hljs-comment"># D/DTn from days since Christ, at midnight.</span>