alexjustesen / speedtest-tracker

Speedtest Tracker is a self-hosted application that monitors the performance and uptime of your internet connection.
https://speedtest-tracker.dev/
MIT License
2.95k stars 108 forks source link

v0.20.3: Timezone not working as documented #1503

Closed alexdelprete closed 2 hours ago

alexdelprete commented 5 months ago

Describe the bug Results are UTC based, despite setting TimeZone to local timezone.

To Reproduce Steps to reproduce the behavior:

  1. Set PostgreSQL to local timezone (Europe/Rome in my case)
  2. Set env in docker compose like this:
    • APP_TIMEZONE="Europe/Rome"
    • DISPLAY_TIMEZONE="Europe/Rome"
  3. Run some tests
  4. See this result: as you can see from the screenshot, times are 2h behind (like it was UTC). Furthermore, the "next speedtest" is shown ignoring DISPLAY_TIMEZONE setting and same goes for results page.

image

Expected behavior I expect times to show in local timezone

Environment (please complete the following information):

alexdelprete commented 5 months ago

Update: I just ran a manual test, and the time is correct for this one (time format is still wrong), but for past tests, times are in UTC.

Last test was a few minutes ago, at 11.25pm, now I ran the manual test and it shows 11.47, but previous test shows 9.25pm while it should be 11.25pm.

Display time format is still wrong.

image image

alexjustesen commented 5 months ago

You can change the table timestamp formats using DATETIME_FORMAT and chats with CHART_DATETIME_FORMAT. Format params can also be found here: https://www.php.net/manual/en/datetime.format.php

Also if you're using TZ environment variable in the app container make sure to remove that.

alexdelprete commented 5 months ago

Removed TZ: past tests still show with wrong timestamps: should be 11.25pm

image

svenvg93 commented 5 months ago

Seem to be the same as I had in https://github.com/alexjustesen/speedtest-tracker/issues/1487

alexdelprete commented 5 months ago

Seem to be the same as I had in https://github.com/alexjustesen/speedtest-tracker/issues/1487

It will always be a problem, because queries to the db assume the db is in UTC. So all these configuration variables are only workarounds.

It's been discussed a lot in the past, and we're still there.

ghost commented 5 months ago

I don't know if its a fix or workaround, I have these in my docker-compose.yml using sqlite db. Now it shows correct scheduled time, and correct time when I run an unscheduled speedtest.

- TZ="Asia/Kolkata"
- APP_TIMEZONE="Asia/Kolkata"
- DISPLAY_TIMEZONE="Asia/Kolkata"
graphixillusion commented 5 months ago

I have the exact same problem: the time is 2h behind the correct time. I have set these two env under the main section:

APP_TIMEZONE="Europe/Rome" DISPLAY_TIMEZONE="Europe/Rome"

and this one under the mariadb10 section:

TZ="Europe/Rome"

Any way to fix this?

mcdoubleyou commented 4 months ago

You can change the table timestamp formats using DATETIME_FORMAT and chats with CHART_DATETIME_FORMAT. Format params can also be found here: https://www.php.net/manual/en/datetime.format.php

Also if you're using TZ environment variable in the app container make sure to remove that.

Hey, I'm looking for the same. I prefer the 24h format.

So I need to set this?

DATETIME_FORMAT="d.m.Y H"

Thanks!

svenvg93 commented 4 months ago

"d.m.Y H"

This one will just show 11.07.2024 18 as date. If thats what you want yess :) Might want to add :ito get also the minutes 11.07.2024 18:06

You can use the table there to compose your own https://www.php.net/manual/en/datetime.format.php

bwirt commented 3 months ago

I had some confusion around this as well. For me, what worked:

Now current and past results show properly in the UI.

Maximilian-Pichler commented 2 months ago

I had some confusion around this as well. For me, what worked:

* Ensure app and db components are using UTC (sh into containers, "date")

* Do not set TZ or APP_TIMEZONE in your docker compose

* Set DISPLAY_TIMEZONE to your local time zone

Now current and past results show properly in the UI.

This fixed it for me

Node815 commented 2 months ago

Came here to say @Maximilian-Pichler's solution worked for me.