How to Set Flask Server Timezone to Gmt
We Have Our Flask Server up and Running. However Requirement Has Come up to Set Server Timzone as Gmt Instead of Utc. I Could Not Find Anything Related to...
We have our flask server up and running. However requirement has come up to set server timzone as GMT instead of UTC. I could not find anything related to timezone in flask documentation. Is this possible? I know it is possible in django.
2 Answers
you can make use of the python datetime.now() instead of the datetime.utcnow(), or you can create a function that will automatically do the timezone conversions on all date objects for you on the sever.
I hope that will help you
This is another option in flask
from datetime import datetime
import pytz
UTC = pytz.utc
IST = pytz.timezone('Asia/Kolkata')
datetime_ist = datetime.now(IST)
print(datetime_ist.strftime('%Y-%m-%d %H:%M:%S'))