Search code examples
djangodateserverlocalhostamazon-elastic-beanstalk

current time on Server (AWS) different from real time


thanks for the help in advance.

I have a django/python project and deployed to AWS with elastic beanstalk. But there is an issue with the current time with the deployed version. I get the current time through django model and render it frontend. It's always one day behind, but it works fine on the localhost.

I have changed the localtime on the server under /etc/localtime to the desired timezone , but this does not address the issue.

Any suggestion will be appreciated! Thanks a lot


Solution

  • I figured out the solution. The issue was that I used " now () " in my model form for initializing the value. I guess that will just take the server restart time and use it for every instance. It works by removing the parentheses from the form field initialization part , this way the now function will be called for each instance.