Advertisement
furas

datetime - timedelta

Aug 4th, 2018
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.25 KB | None | 0 0
  1. import datetime
  2.  
  3. periods = [0, 178, 356, 534]
  4.  
  5. today = datetime.datetime.today()
  6.  
  7. dates = []
  8.  
  9. for n in periods:
  10.     dates.append( (today - datetime.timedelta(days=n)).strftime("%Y%m%d %H:%M:%S %Z") )
  11.  
  12. print(dates)
  13.  
  14. # and now use loops with `dates`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement