Timestamp 3 months ago

I have a small script where I get data for the last few months based on a timestamp. Now I am using the current day and the set date (currently May). Here is how I define it:

today_time = int(time.mktime(date.today().timetuple())*1000000) earlier_time = int(time.mktime(datetime.date(2011,05,01).timetuple())*1000000) 

I want to change earlier_time from the set date (currently 2011.05.01) to, say, 90 days. I could not find how to do this, so your help would be greatly appreciated.

+6
source share
1 answer
 import datetime now = datetime.datetime.now() then = now - datetime.timedelta(days=90) 
+19
source

Source: https://habr.com/ru/post/894567/


All Articles