Answer the question
In order to leave comments, you need to log in
Date offset 2000?
import datetime
date_time = datetime.datetime.now()
cur_date = date_time.strftime("%Y-%m-%d %H:%M:%S")
displacement_2000 = "'" + str(int(cur_date[0:4]) + 2000) + cur_date[4:len(cur_date)] + "'"
print(displacement_2000)
Answer the question
In order to leave comments, you need to log in
from datetime import datetime
print(datetime.fromordinal((datetime.now().toordinal() + 730485)))
print(datetime.fromtimestamp((datetime.now().timestamp() + 730485 * 86400)))
If you occasionally encounter this kind of task, install the python-dateutil library (it will take a couple of tens of seconds) and have fun with dates to your heart's content, simply and obviously.
>>> from datetime import datetime
>>> from dateutil.relativedelta import relativedelta
>>> now = datetime.today()
>>> print(now + relativedelta(years =+ 2000))
4017-02-24 21:11:20.779300
>>> print(now + relativedelta(months =+ 5))
2017-07-24 21:11:20.779300
>>> import datetime
>>>
>>> date_time = datetime.datetime.now()
>>> date_time_2000 = date_time.replace(year=date_time.year + 2000)
>>> date_time.strftime("%Y-%m-%d %H:%M:%S")
'2017-02-26 17:55:44'
>>> date_time_2000.strftime("%Y-%m-%d %H:%M:%S")
'4017-02-26 17:55:44'
>>>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question