Answer the question
In order to leave comments, you need to log in
How to add nth number of days to a date?
The task is to add a certain number of days when choosing a certain status. Let's say that when you make a post, today's date is saved automatically, but there is a field, the publication end date, and 3 days should be added there, but if you select a different status, this parameter can be 1 day. I understand that this should be done using datatime and timedelta, if there are code examples, please tell me. Or perhaps there is a ready-made widget.
Answer the question
In order to leave comments, you need to log in
import datetime
dt = datetime.datetime.now()
dt += datetime.timedelta(days=3)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question