mardi 15 août 2017

How to do statements with time value

In my Django python code I want to greet the visitor according to the time of the day. It always gives back 'Good afternoon'(even though it isn't) but can't see why.

this is from my views.py:

#import time
#import datetime
#from time import strftime
#from django.utile import timezone

def greet(request):
request.session['greet'] = 'Good day'
currentTime = time.strftime('%H')
int(currentTime)
if currentTime < 12 :
    request.session['greet'] = 'Good morning'
if currentTime >= 18 :
    request.session['greet'] = 'Good afternoon'
else :
    request.session['greet'] = 'Good evening'

return request.session['greet']

Aucun commentaire:

Enregistrer un commentaire