Ad Widget

Collapse

Frontend's wrong timezone display

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • markfree
    Senior Member
    • Apr 2019
    • 868

    #1

    Frontend's wrong timezone display

    I'm getting a timestamp in unix format that is being displayed in the frontend with the wrong timezone.

    For example:
    My item receives a value of "1657361472" and its unit is set as "unixtime".
    When I check the latest data, the item displays the wrong time.

    That value should be translated as "2022-07-09 10:11:12" in the frontend, but it is displaying "2022-07-09 07:11:12".
    Click image for larger version

Name:	wrong_timezone.png
Views:	982
Size:	4.3 KB
ID:	447592
    The value is correct, but the presentation is not.

    Of course, my frontend is configured with GMT-3, which is my time zone.

    How can I display the timestamp value ignoring my frontend's timezone?
  • Markku
    Senior Member
    Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
    • Sep 2018
    • 1781

    #2
    1657361472 = Saturday, July 9, 2022 10:11:12 AM (UTC)

    and you are in UTC-3

    so displaying 07:11:12 seems correct to me.

    AFAIK the unix timestamp is based on UTC, not on local time.

    I guess you need to change your frontend configuration if you want to show the data in other timezone.

    Markku

    Comment

    • Hamardaban
      Senior Member
      Zabbix Certified SpecialistZabbix Certified Professional
      • May 2019
      • 2713

      #3
      Pls check this: https://www.zabbix.com/documentation...e/user_profile

      Comment

      • markfree
        Senior Member
        • Apr 2019
        • 868

        #4
        I understand.
        I just thought Zabbix would not consider the profile timezone when displaying the data (a good thing, I know).
        At the source host, I had to transform the collected timestamp to make it standard UTC.
        It would be nice to have a "unixtimenoutc" as a unit type, I guess.

        Comment

        • Markku
          Senior Member
          Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
          • Sep 2018
          • 1781

          #5
          You can also use item preprocessing to fix the value in Zabbix.

          Markku

          Comment

          • markfree
            Senior Member
            • Apr 2019
            • 868

            #6
            Originally posted by Markku
            You can also use item preprocessing to fix the value in Zabbix.
            Indeed, but I don't see how.

            In my example, the value "1657361472" represents, "Sat Jul 09 2022 10:11:12". Since it was captured from another system, it was originally set as UTC-3.

            For it to become UTC-0, I could just add 10800 seconds (3h). It would become "1657372272" which represents "Sat Jul 09 2022 13:11:12".

            How could I add those 3h with preprocessing?

            Comment

            • Markku
              Senior Member
              Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
              • Sep 2018
              • 1781

              #7
              Based on the documentation (https://www.zabbix.com/documentation...ing/javascript) this JavaScript preprocessing step could work:

              return value + 10800;

              Let us know how it goes.

              Markku

              Comment

              • markfree
                Senior Member
                • Apr 2019
                • 868

                #8
                I forgot about Javascript.

                Anyhow, I actually altered the timezone at the source. Now, the unix time collected is matching UTC-0.

                Thanks a lot for all considerations.

                Comment

                Working...