title: Python get current time in right timezone
body: <p>Right now I use</p>
  
  <pre><code>import datetime
  print(datetime.datetime.now().strftime("%X"))
  </code></pre>
  
  <p>to display the current time as a string.<br>
  Problem is, my computer is running in <code>Europe/Berlin</code> time zone, and the offset of +2 to UTC is not accounted here.
  Instead of <code>19:22:26</code> it should display <code>21:22:26</code>
  Also different to the other answers I found here, I do not store it by calling</p>
  
  <pre><code>datetime.datetime(2014, 7, 10, 18, 44, 59, 193982, tzinfo=&lt;UTC&gt;)
  </code></pre>
  
  <p>but </p>
  
  <pre><code>datetime.datetime.now()
  </code></pre>
  
  <p>so I tried (and failed) the following:</p>
  
  <pre><code>&gt;&gt;&gt; from pytz import timezone
  &gt;&gt;&gt; datetime.datetime.now().astimezone(timezone('Europe/Berlin'))
   ValueError: astimezone() cannot be applied to a naive datetime
  </code></pre>
  
  <p><br></p>
  
  <h3>Edit:</h3>
  
  <h1>Answer</h1>
  
  <p><em>Can't post as answer, as this question is marked closed</em></p>
  
  <p>The server I had this issue with doesn't exists any longer.
  Anyway, here are some other things worth checking:</p>
  
  <ul>
  <li>Is the timezone of your server/system set up correctly?
  
  <ul>
  <li>VMs or docker containers might be out of sync with the host, that's worth checking.</li>
  </ul></li>
  <li>Is the time on that computer correct? You don't ended up with +2 hours after changing the timezone?</li>
  </ul>