[Fixed]-Python DateTime if statement behaves different in Azure.(Django WebApp)

1πŸ‘

βœ…

It should be a timezone issue. As when we need to parse timestamp to datetime object, it will need the timezone setting, and by default it will leverage the system timezone. And the timezone on Azure services are all the same as America/Los_Angeles.

So you need to set your local timezone in your code, E.G:

import pytz
localtz = pytz.timezone('Asia/Hong_Kong')
starttijd = (datetime.datetime.fromtimestamp(appointment['start'],tz=localtz)).strftime('%H%M')
print starttijd

…

πŸ‘€Gary Liu

Leave a comment