Popular recipes by Kent Tenney http://code.activestate.com/recipes/users/4166394/2008-08-13T18:56:29-07:00ActiveState Code RecipesGet a posix timestamp from a type 1 uuid (Python) 2008-08-13T18:56:29-07:00Kent Tenneyhttp://code.activestate.com/recipes/users/4166394/http://code.activestate.com/recipes/576420-get-a-posix-timestamp-from-a-type-1-uuid/ <p style="color: grey"> Python recipe 576420 by <a href="/recipes/users/4166394/">Kent Tenney</a> (<a href="/recipes/tags/datetime/">datetime</a>, <a href="/recipes/tags/time/">time</a>, <a href="/recipes/tags/timestamp/">timestamp</a>, <a href="/recipes/tags/uuid/">uuid</a>). </p> <p>The uuid timestamp is 60 bits, the number of 100 nanosecond increments since Oct. 15, 1582 This simple function returns a value which makes datetime.datetime.fromtimestamp() happy.</p> <p>It simply rewinds the code in the standard library's uuid1 function:</p> <pre class="prettyprint"><code>nanoseconds = int(time() * 1e9) # 0x01b21dd213814000 is the number of 100-ns intervals between the # UUID epoch 1582-10-15 00:00:00 and the Unix epoch 1970-01-01 00:00:00. timestamp = int(nanoseconds/100) + 0x01b21dd213814000 </code></pre>