Subtract seconds from datetime in python
datetime, python, python-3.x
Solution
Using the `datetime` module indeed:
import datetime
X = 65
result = datetime.datetime.now() - datetime.timedelta(seconds=X)
You should read the documentation of this package to learn how to use it!
Problem
I have an int variable that are actually seconds (lets call that amount of seconds `X`). I need to get as result current date and time (in datetime format) minus `X` seconds. Example If `X` is 65 and current date is `2014-06-03 15:45:00`, then I need to get the result `2014-06-03 15:43:45`. Environment I'm doing this on Python 3.3.3 and I know I could probably use the `datetime` module but I haven't had any success so far.