GTM - JS Variable - Date/Time

    0

    0

    Wesley van Wyk

    The code tries to convert a timestamp to an ISO string. If an error occurs, the code returns "unknown".

    function() {
      try {
      var timestamp = new Date(); timestamp.setHours(timestamp.getHours() + 2);
      var time = timestamp.toISOString();
      return time;
      } catch(e) {
      return "unknown";
      }
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.