Python DateTime if statement behaves different in Azure.(Django WebApp)
Question: So i'm writing a little Django webApp. It uses JSON data from a API to render
everything. In localhost, everything runs fine. But in Azure it does not.  
  
The is somewhere in this code:

    
    
    for appointment in appointmentsMaandag:
        starttijd = (datetime.datetime.fromtimestamp(appointment['start'])).strftime('%H%M')
        SuMa = 0
        if  800 <= int(starttijd) < 850:
            SuMa = 0
        elif  850 <= int(starttijd) < 940:
            SuMa = 1
        elif  940 <= int(starttijd) < 1050:
            SuMa = 2
        elif  1050 <= int(starttijd) < 1140:
            SuMa = 3
        elif  1140 <= int(starttijd) < 1240:
            SuMa = 4
        elif  1240 <= int(starttijd) < 1350:
            SuMa = 5
        elif  1350 <= int(starttijd) < 1440:
            SuMa = 6
        elif  1440 <= int(starttijd) < 1530:
            SuMa = 7
        else:
            SuMa = 8
        break
    

  
  
In azure, this always outputs the `ELSE`. `SuMa = 8` in this case. In
Localhost it does work. Since I have no experience whatsoever with azure, I
was wondering if any of you could help me.  
  
I use VS 2015 with Python Tools.


Answer: 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
    

...

