I would like to substract months from a timestamp in second. Here is what I'm doing:
>>> ts = 1454284800
>>> date_object = datetime.datetime.strptime(time.strftime('%Y%m%d', time.gmtime(1454284800)), '%Y%m%d')
>>> date_object
datetime.datetime(2016, 2, 1, 0, 0)
>>> date_substract = date_object - datetime.timedelta(9*365/12.0)
>>> date_substract
datetime.datetime(2015, 5, 3, 6, 0)
>>>
It depends on the value for the number of months I want to substract, but for 9 months for exemple, days datetime.datetime(2015, 5, 3, 6, 0) are wrong. Is there a better way to substract months, which would only change number of months and not days as well.
Thanks in advance.