Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong UTC time in containers? #113

Closed
Vvaltz opened this issue Feb 13, 2020 · 2 comments
Closed

Wrong UTC time in containers? #113

Vvaltz opened this issue Feb 13, 2020 · 2 comments

Comments

@Vvaltz
Copy link

Vvaltz commented Feb 13, 2020

Using Windows 10, Docker Desktop

In container:
Thu Feb 13 17:49:33 Vilnius 2020
Google says:
Thu Feb 13 18:49:33 Vilnius 2020

Tried:

apt-get update && apt-get install tzdata
ENV TZ=Europe/Vilnius
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

All other containers that use ubuntu images are OK. This is the first I encountered;

Please help ? I'm not too familiar with docker, and this is quite a problem if you ask me

@tiangolo
Copy link
Owner

I think you are getting an incorrect timezone, not an incorrect UTC time.

Hmm, whenever you deploy your container it will probably be in a datacenter that might be in a different timezone different than yours, so I'm not sure how useful it would be to assume a timezone in your container.

It would probably be better to use UTC in your code. Or if you are going to depend on timezones, it should be the timezones of your clients or timezones defined in your settings.

For example with things like:

from datetime import datetime

now = datetime.utcnow()
print(now)

Otherwise, please provide more info and a minimal self-contained example that shows the error.

Currently, I have no way of knowing how you are getting those dates, or how to help you debug it.

Also, it seems you created the exact same issue in 2 repos: tiangolo/uvicorn-gunicorn-fastapi-docker#29

But it's still not clear where (in which repo) is your problem...

@Vvaltz
Copy link
Author

Vvaltz commented Apr 14, 2020

Same as tiangolo/uvicorn-gunicorn-fastapi-docker#29

@Vvaltz Vvaltz closed this as completed Apr 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants