Hello,
This works:
from django.utils import timezone
from datetime import datetime
today = timezone.now()
date1 = datetime(1991, 12, 23, tzinfo=today.tzinfo)
apart = today-date1
years = apart.days/365
print(years)
This works great for what I need it for!
thanks,
Brandon Keith Biggs <http://www.brandonkeithbiggs.com/>
On 7/12/2015 4:26 PM, lars van Gemerden wrote:
question is a bit vague, but look at python datetime.datetime and
datetime.timedelta
On Sunday, July 12, 2015 at 1:02:55 PM UTC+2, Brandon Keith Biggs wrote:
Hello,
using the django.utils.timezone.now() function, how can I find the
difference from another date in years?
For example, if I have two dates like:
date1 = (1991, 12, 23)
date2 = (1995, 12, 6)
How do I use the current time to get 23 from the first and 19 from
the second?
thank you,
--
Brandon Keith Biggs <http://www.brandonkeithbiggs.com/>
--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to django-users+unsubscr...@googlegroups.com
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com
<mailto:django-users@googlegroups.com>.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/3542021d-646a-4229-b144-ea7fd58e51fc%40googlegroups.com
<https://groups.google.com/d/msgid/django-users/3542021d-646a-4229-b144-ea7fd58e51fc%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/55A28BA4.5090502%40gmail.com.
For more options, visit https://groups.google.com/d/optout.