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? #29

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

Wrong UTC time? #29

Vvaltz opened this issue Feb 13, 2020 · 3 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.

@Vvaltz
Copy link
Author

Vvaltz commented Apr 14, 2020

Sorry for the late response. Turns out it was an issue with Docker for Windows:
docker/for-win#4526
The clock would drift when the host machine went into rest mode. Sorry for taking your time.
It was just a coincidence I was trying to do something time-specific with these containers.

@Vvaltz Vvaltz closed this as completed Apr 14, 2020
@tiangolo
Copy link
Owner

Cool! Thanks for reporting back and closing the issue 👍

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