SHARE
TWEET

datetime - timedelta

furas Aug 4th, 2018 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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`
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top