Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-24133

JavaScript Date.parser() not working properly with timezone

XMLWordPrintable

    • Icon: Problem report Problem report
    • Resolution: Duplicate
    • Icon: Major Major
    • None
    • None
    • Proxy (P), Server (S)
    • None

      Steps to reproduce:

      1. Create an item with the JavaScript preprocessing step with the following parameter:
      var timestampWithTimezone = "2024-02-20T13:16:00+0100";
      //var timestampWithTimezone = "2024-02-20T13:16:00+01:00";
      var date = new Date(timestampWithTimezone);
      var unixTime = date.getTime() / 1000;
      return unixTime;
      1. Test it.

      Result:
      Wrong unixtime is returned:
      Returned 1708074960 which converts to 2024-02-16T09:16:00
      Different inputs have different results: 

      • 2024-02-20T13:16:00+0100 - doesn't work
      • 2024-02-20T13:16:00+01:00 - works as expected

      Expected:
      Correct conversion to 2024-02-20T13:16:00+0100

      According to the:
      https://github.com/svaarala/duktape/blob/master/doc/datetime.rst
      and
      https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#date_time_string_format

      We should support both cases.

            zabbix.dev Zabbix Development Team
            vcredidio Victor Breda Credidio
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: