My time zone is UTC + 5.
So, when I do datetime.datetime.now (), it gives:
2012-07-14 06:11:47.318000
#note its 6AM
I wanted to subtract 5hours from it so that it became equal datetime.datetime.utcnow(), so I did:
import time
from datetime import datetime, timedelta
dt = datetime.now() - timedelta(hours=time.timezone/60/60)
print dt
"""
Here 11 is not the PM its AM i double check it by doing
print dt.strftime('%H:%M:%S %p')
#gives 11:11:47 AM
"""
You see instead of subtracting 5 hours, does it add 5 hours to datetime ?? Am I something wrong here?
source
share