title: How to round datetime previous 10 minute with python
body: <p>I want to get the last 10 minutes in python to be fully divisible by 10.</p>
  
  <p>It shouldn't round to the next 10 minutes, it must be always previous 10 minutes.</p>
  
  <p>For example, output should be as follows:</p>
  
  <blockquote>
    <p>2019-10-04 20:45:34.903000  -> 2019-10-04 20:40</p>
    
    <p>2019-10-04 20:48:35.403000  -> 2019-10-04 20:40</p>
    
    <p>2019-10-04 20:42:21.903000  -> 2019-10-04 20:40</p>
    
    <p>2019-10-04 20:50:21.204000  -> 2019-10-04 20:50</p>
    
    <p>2019-10-04 20:59:49.602100  -> 2019-10-04 20:50</p>
  </blockquote>
  
  <pre><code>import datetime
  
  def timeround10(dt):
      #...
  
  
  print timeround10(datetime.datetime.now())
  </code></pre>