title: Convert date to human-readable format (tomorrow, 2 days ago) in Python
body: <p>I am trying to convert the python date to human-readable format like &quot;tomorrow&quot;, &quot;2 days ago&quot;, &quot;in a week&quot;, etc.</p>
  <p>I can write some snippets like below, but is there any python package available for the same? I found the <a href="https://dateparser.readthedocs.io/en/latest/index.html" rel="nofollow noreferrer">dateperser</a> package to parse the human-readable format to date object, but not the other way.</p>
  <p>Thanks.</p>
  <pre><code>from datetime import date, timedelta
  
  today = date.today()
  
  for d in range(-10, 10, 1):
      next = today + timedelta(days=d)
      diff = (next - today).days
  
      if diff == 0:
          s = &quot;Today&quot;
      elif diff == -1:
          s = &quot;Yesterday&quot;
      elif diff == 1:
          s = &quot;Tomorrow&quot;
      elif diff == 2:
          s = &quot;Day after Tomorrow&quot;
      elif abs(diff) &lt; 4:
          s = f&quot;{abs(diff)} days ago&quot; if diff &lt; 0 else f&quot;In {abs(diff)} days&quot;
      elif abs(diff) &lt;= 7:
          str = &quot;Last&quot; if diff &lt; 0 else &quot;Next&quot;
          day = next.strftime(&quot;%A&quot;)
          s = f&quot;{str} {day}&quot;
      else:
          day = next.strftime(&quot;%d-%m-%Y&quot;)
          s = f&quot;On {day}&quot;
  
      print(f&quot;{next} ({d}): {s}&quot;)
  </code></pre>
  <p>Output:</p>
  <pre><code>2021-09-09 (-10): On 09-09-2021
  2021-09-10 (-9): On 10-09-2021
  2021-09-11 (-8): On 11-09-2021
  2021-09-12 (-7): Last Sunday
  2021-09-13 (-6): Last Monday
  2021-09-14 (-5): Last Tuesday
  2021-09-15 (-4): Last Wednesday
  2021-09-16 (-3): 3 days ago
  2021-09-17 (-2): 2 days ago
  2021-09-18 (-1): Yesterday
  2021-09-19 (0): Today
  2021-09-20 (1): Tomorrow
  2021-09-21 (2): Day after Tomorrow
  2021-09-22 (3): In 3 days
  2021-09-23 (4): Next Thursday
  2021-09-24 (5): Next Friday
  2021-09-25 (6): Next Saturday
  2021-09-26 (7): Next Sunday
  2021-09-27 (8): On 27-09-2021
  2021-09-28 (9): On 28-09-2021
  </code></pre>