I’m wondering: where does Lemmy UI get the timezone for the time stamp on posts?

We are using Lemmy in docker. Two of the five containers in the stack have tzdata, and all of them are set to UTC right now. But when I hover over a post’s relative time stamp to get the precise time it was posted, I was surprised to see UTC -6.

I’m in UTC -6, and the host that the docker stack is running on is currently set to UTC -6.

Basically, I can go to all the trouble to set the env in docker-compose to set the correct time zone for the containers, but I’m wondering if I need to bother. Any feedback would be helpful as far as best practices for setting time zones to make posts have the right time stamp and for making logs readable.

Thanks in advance!

  • foo@withachanceof.com
    link
    fedilink
    arrow-up
    5
    ·
    edit-2
    11 months ago

    I’d have to look at the code to be sure, but I’d guess it converts the timestamp into the browser’s timezone. You could test this by changing the timezone on your computer and seeing how Lemmy displays it.

    At least that’s how I’d build it. Keeping backend times in UTC and then converting on the frontend to the user’s set timezone is generally a best practice. Using non-UTC times on servers is just asking for trouble.

  • Dessalines@lemmy.mlM
    link
    fedilink
    arrow-up
    2
    ·
    11 months ago

    You should make sure your docker just uses the same time as the system its installed on, which is the default. Lemmy’s postgres uses UTC, so you’re gonna have a bad time if you try to manually override the docker default.

    • RotaryKeyboard@lemmy.ninjaOP
      link
      fedilink
      English
      arrow-up
      2
      arrow-down
      1
      ·
      11 months ago

      I just want to make sure I understand.

      The docker containers need to be set to the same time zone as the docker host. Is that right?

      Our docker host has been set to America/Denver for weeks, but the containers have been UTC, and we haven’t had any unusual behavior.

      I did set the postgres container’s time zone to America/Denver a few hours ago and also saw no strange behavior.

      I took a snapshot before I did that, so I can roll back, but I’m wondering what bad things would happen that I should look out for.

      • Dessalines@lemmy.mlM
        link
        fedilink
        arrow-up
        1
        ·
        11 months ago

        You should not have to tweak anything with docker. It by default uses the time and time zone of your host machine.