1👍
✅
1👍
import datetime
if some_datetime > datetime.datetime.now() + datetime.timedelta(days=10):
return "some_date is greater than the current datetime plus 10 days"
See timedelta doc: http://docs.python.org/library/datetime.html#datetime.timedelta
- [Answered ]-Django Rest Framework Angulars upload file using ModelSerializer
- [Answered ]-How to send an email on successful test completion in django
0👍
from datetime import datetime
datetime_now = datetime.now()
‘datetime_now’ variable now has the current time.
Use this variable to compare with event start time and print or do relevant stuff for that condition.
for eg:
if event_start_time > datetime_now:
print "upcoming"
Source:stackexchange.com