change datetime format in python
<p>I am getting this datetime in this format from my database.</p>

<pre><code>2016-09-13T08:46:59.953948+00:00
</code></pre>

<p>I want to change this date into format like </p>

<pre><code>13 sep 2016 08:46:59
</code></pre>

<p>I have used datetime module like</p>

<pre><code>import datetime
datetime.datetime.strptime(2016-09-13T08:46:59.953948+00:00, 'changing format')
</code></pre>

<p>But it is giving error </p>

<pre><code>TypeError at /admin/help
must be string, not datetime.datetime
</code></pre>

<p>By importing Datetime and Arrow you can convert into your required format. Arrow is a python library to format date &amp; time.</p>

<pre><code>import arrow
import datetime

today = arrow.utcnow().to('Asia/Calcutta').format('YYYY-MM-DD HH:mm:ss')
'2016-09-13 15:57:38'

current_date = datetime.datetime.strptime(today, "%Y-%m-%d %H:%M:%S").strftime('%d-%B-%Y %H:%M:%S')
'13-September-2016 15:57:38'
</code></pre>

<p>To know more about Arrow <a href="https://micropyramid.com/blog/python-arrow-to-show-human-friendly-time/" rel="nofollow">https://micropyramid.com/blog/python-arrow-to-show-human-friendly-time/</a></p>

python django