<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://simson.net/wiki/index.php?action=history&amp;feed=atom&amp;title=ISO_8601</id>
	<title>ISO 8601 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://simson.net/wiki/index.php?action=history&amp;feed=atom&amp;title=ISO_8601"/>
	<link rel="alternate" type="text/html" href="https://simson.net/wiki/index.php?title=ISO_8601&amp;action=history"/>
	<updated>2026-05-01T10:53:33Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.37.1</generator>
	<entry>
		<id>https://simson.net/wiki/index.php?title=ISO_8601&amp;diff=805&amp;oldid=prev</id>
		<title>Simson: Created page with &quot;Converting between ISO~8601 and Unix Timestamps.  Converting ISO~8601 strings to Python `datetime` objects is  straightforward:  &lt;pre&gt; import dateutil.parser tstr = &quot;2008-01-02T1...&quot;</title>
		<link rel="alternate" type="text/html" href="https://simson.net/wiki/index.php?title=ISO_8601&amp;diff=805&amp;oldid=prev"/>
		<updated>2011-08-10T02:24:52Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;Converting between ISO~8601 and Unix Timestamps.  Converting ISO~8601 strings to Python `datetime` objects is  straightforward:  &amp;lt;pre&amp;gt; import dateutil.parser tstr = &amp;quot;2008-01-02T1...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Converting between ISO~8601 and Unix Timestamps.&lt;br /&gt;
&lt;br /&gt;
Converting ISO~8601 strings to Python `datetime` objects is  straightforward:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import dateutil.parser&lt;br /&gt;
tstr = &amp;quot;2008-01-02T10:20:33-0800&amp;quot;&lt;br /&gt;
t = dateutil.parser.parse(tstr)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These objects can then be converted to Unix timestamps:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import time&lt;br /&gt;
tval = time.mktime(t.timetuple())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Java programmers can use the Java function `javax.xml.bind.DatatypeConverter.parseDateTime`.&lt;br /&gt;
&lt;br /&gt;
With Python Conversion from Unix timestamp values to ISO~8601 needs to&lt;br /&gt;
be augmented with an explicit GMT reference, since this is not&lt;br /&gt;
provided by Python&amp;#039;s `datetime` package, which is unaware of UTC offsets:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; dt = datetime.datetime.utcfromtimestamp(101106)&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; dt.isoformat()+&amp;quot;Z&amp;quot;&lt;br /&gt;
&amp;#039;1970-01-02T04:05:06Z&amp;#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The conversion can also be performed with&lt;br /&gt;
the function \emph{strftime} that is present in many programming&lt;br /&gt;
languages. This function allows conversion to either GMT or local&lt;br /&gt;
time. Once again, the programmer needs to be cognizant of the need to&lt;br /&gt;
explicitly reference the UTC offset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; t = 101106&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; time.strftime(&amp;quot;%FT%TZ&amp;quot;,time.gmtime(t))                                                                              &lt;br /&gt;
&amp;#039;1970-01-02T04:05:06Z&amp;#039;&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; time.strftime(&amp;quot;%FT%T%z&amp;quot;,time.localtime(t))                                                                          &lt;br /&gt;
&amp;#039;1970-01-01T23:05:06-0500&amp;#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Simson</name></author>
	</entry>
</feed>