I am trying to set expire_time
in my django model to be midnight of user's selected date with timezone aware. But I am not able to get it properly. Can anyone tell me how I can do it or where I am making mistake in my code?
My codes are,
date = datetime.strptime(str(request.POST.get('expire') + ', 23:59:59'),
'%Y-%m-%d, %H:%M:%S')
tz = timezone.get_current_timezone()
date_tz = tz.localize(date)
createEventInDB.ev_expire = date_tz
try:
createEventInDB.save()
except Exception as e:
error = e
So if I select date which is December 1st 2015, it would be posting as 2015-12-1
I want to save data in database like 2015-12-01 23:59:59
. I want to give whole day to user. My current timezone is America/Chicago. I have set active timezone by ip. So I want to make it like user can post from anywhere but timezone must be UTC aware and expire at midnight. Can anyone tell me how can I make it possible?