V
V
vladidik2020-08-14 12:30:34
Python
vladidik, 2020-08-14 12:30:34

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

1 answer(s)
S
Sergey Tikhonov, 2020-08-15
@tumbler

import datetime
dt = datetime.datetime.now()
dt += datetime.timedelta(days=3)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question