Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

timestamp from 3months ago

I've a small script where I'm getting data from the last few months, based on the timestamp. Right now I'm using current day and a set date (currently May). Here's how I'm defining it:

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

I'd like to change earlier_time from a set date (currently 2011,05,01) to, say, 90 days. I couldn't find how to do this, so your help would be very appreciated.

like image 929
janecs Avatar asked Aug 08 '11 17:08

janecs


1 Answers

import datetime

now = datetime.datetime.now()
then = now - datetime.timedelta(days=90)
like image 77
Ned Batchelder Avatar answered Sep 21 '22 08:09

Ned Batchelder