Ad Widget

Collapse

Preprocessing datetime to unix time

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • martinsa
    Junior Member
    • Aug 2022
    • 2

    #1

    Preprocessing datetime to unix time

    Hello
    I am really new zbx, I tried in many ways change datetime in preprocessing -Items to unixtime, but still with issue
    I have YYYY-MM-DDThh:mm:ssTZD and I need convert it to Unixtime (maybe in JS)
    return date.parse(value) or Date.parse($("#yourCustomDate).val()) is note work.


    2022-05-06T12:21:24Z ti Unixtime

    Do you have any idea how to
    Thanks
  • ISiroshtan
    Senior Member
    • Nov 2019
    • 324

    #2
    Put following code into JS preprocessing:
    Code:
    const date = new Date(value);
    const timestampSeconds = Math.floor(date.getTime() / 1000);
    return(timestampSeconds)
    Should work​.

    Comment

    Working...