Forums

How do I change time / timezone?

Hi, I am running schedule tasks, and the code checks the server using datetime.now() to run the tasks.

However, PythonAnywhere timezone is set to UTC (I need UTC +5:30) , which is leading to false positives to my code.

I have tried date -s command in bash, also, tried appending TZ = 'Asia/Calcutta'; export TZ; to $HOME/.profile, however the changes won't persist. (I am supposing that it requires server reboot, I don't know how to do that, as there's no root access).

Also, I do not want to use pytz. Is there a solution ?

Try changing the environment variable in the scheduled task's command line -- that is, instead of scheduling

/home/shariqx/yourscript.py

...you would specify

TZ='Asia/Calcutta' /home/shariqx/yourscript.py

(Note there are no spaces around the = sign.)

Hi, This doesnt seem to work for me... I need to put 'Asia/Jerusalem' (UTC +2) as the time zone but even when i change it in the code or bashrc or anywhere else the server time stays on UTC +0 for tasks...

When i am trying to run a task it will run it depending on the time I Have set before..

Thanks in advance for the help

Currently you can't change the system time on our servers, so it would be UTC. You'd need to adjust the schedule timing with your timezone.

I don’t know if this info is written somewhere but it would be nice to add it Thank you very much

It's on the top of the Task page.

Hi, it would be nice if you add this option. it is essential.

Noted!

This is not true. I was able to get it changed and now I forgot myself how did I do it back in the day

I think you must be thinking about some other part of the system; you can (for example) change the timezone used by some kinds of logging by telling your code to adjust timestamps used when it writes out dates to files (see [this help page[(https://help.pythonanywhere.com/pages/SettingTheTimezone)) but the specific thing that is being asked about here -- the timezone used for scheduled tasks and for the time at the top of the "Tasks" page -- has never been something that you can change.