If I run this in VS Code, it gives me the correct local time:
from time import strftime
time = strftime("%H:%M %p")
print(time)
But if I use the same code in a Django project, my website displays a time which is 8 hours behind local time.
from time import strftime,localtime
def time_display(request):
context = {
"date":strftime("%b %d, %Y",localtime()), #DOESN'T DISPLAY LOCAL TIME
"time1": strftime("%H:%M %p",localtime()), #DOESN'T DISPLAY LOCAL TIME
"time3": strftime("%H:%M %p"), #DOESN'T DISPLAY LOCAL TIME
}
return render(request,'time_display.html',context)
How do I fix it to display correct local time where the webpage is being viewed?