× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

How to turn this into a Python Datetime

Martin Czygan
Jun 29, 2015
<p>Here's a overview of the format codes: <a href="https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior" rel="nofollow">https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior</a></p> <blockquote> <p>The full set of format codes supported varies across platforms, because Python calls the platform C library’s strftime() function, and platform variations are common. To see the full set of format codes supported on your platform, consult the strftime(3) documentation.</p> </blockquote> <p>But your example should be parseable with <code>%A %B %d, %Y</code>:</p> <pre><code>&gt;&gt;&gt; import datetime &gt;&gt;&gt; datetime.datetime.strptime("Tuesday July 7, 2015", "%A %B %d, %Y") datetime.datetime(2015, 7, 7, 0, 0) </code></pre> <p>This tip was originally posted on <a href="http://stackoverflow.com/questions/31015648/How%20to%20turn%20this%20into%20a%20Python%20Datetime/31015705">Stack Overflow</a>.</p>
comments powered by Disqus