Reputation: 6058
I'm confused on datetime comparison with Django datetime field, here is the code
now = datetime.now()
delta = talk.when + timedelta(minutes=(talk.duration + 10))
if now > delta:
return True
return False
talk
is just datetime field,
duration
is integer field
now
- should have hours equal to 17:43
however I've 5:43
(datetime.datetime(2012, 5, 14, 5, 43, 24, 228401)
)
What is the problem, whats wrong in the code?
Now it works
I just added USER_ENV_TZ variable with my local timezone and used utcnow
if os.getenv('ENV_USER_TZ', None):
TIME_ZONE = os.getenv('ENV_USER_TZ') # changed to UTC
Thanks, Sultan
Upvotes: 1
Views: 439
Reputation: 6058
Now it works
I just added USER_ENV_TZ variable with my local timezone and used utcnow
suggested by @ BluePeppers
if os.getenv('ENV_USER_TZ', None):
TIME_ZONE = os.getenv('ENV_USER_TZ') # changed to UTC
Thank you all
Upvotes: 1