this question has answer here:
i'm working in django, standard python solution ok too.
i'm converting code uses naive-datetime use aware-datetime.
below original code:
today = datetime.today() myclass.objects.filter(datetimefield__range=(today, today+datetime.timedelta(1)) ) how convert use timezone-aware time?
if time jun/3rd/7:20pm locally,
i'd datetime range of [jun/3rd/00:00am, jun/4th/00:00am] (midnight midnight include now)
i know old, using django.utils.timezone straightforward. (nothing concerning timezones ever seems easy me)
# datetime.date my_date = timezone.now().date() dt_at_local_midnight = timezone.make_aware( timezone.datetime.combine(my_date, time.min), timezone.get_current_timezone()) and alternative might better listed in first comment below.
Comments
Post a Comment