Skip to Content
Menu
This question has been flagged
1 Reply
3297 Views

Could you please give an exact/complete code for finds date difference in days. The idea is we are using membership module and we want to display still how many days remain before membership expires.

Thank you  

Avatar
Discard
Best Answer

You can use this date difference.

from datetime import datetime,date,timedelta
from dateutil.relativedelta import relativedelta
today = datetime.now()
today_str = today.strftime("%Y-%m-%d")
diff = relativedelta(datetime.strptime(today_str,'%Y-%m-%d').date(),datetime.strptime(your_date,'%Y-%m-%d').date())
Avatar
Discard
Related Posts Replies Views Activity
0
Nov 24
107
0
Mar 24
128
0
Feb 24
312
2
Jul 23
1575
0
Dec 22
47