Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
4654 Visualizzazioni

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
Abbandona
Risposta migliore

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
Abbandona
Post correlati Risposte Visualizzazioni Attività
0
ago 25
708
1
mar 25
1766
0
mar 24
1120
0
feb 24
1355
2
lug 23
3105