Skip to main content

📌  We do our best to ensure that the code in these articles works as advertised, but please be aware that Zapier Support does not officially help with code steps due to their advanced nature. Feel free to comment on the article or ask in the Zapier Community, where we have code-savvy users.

The Purpose

To parse a timestamp into its parts:

  1. YYYY - Year
  2. MM - Month
  3. DD - Day
  4. hh - Hour
  5. mm - Minutes
  6. ss - Seconds

How to Configure

Copy the Code

NOTE: This converts in UTC time zone.

let Timestamp = new Date(inputData.Timestamp).toISOString();

let Year = Timestamp.split("-")"0];
let Month = Timestamp.split("-")"1].split("-")"0];
let Day = Timestamp.split("-")"2].split("T")"0];
let Hour = Timestamp.split("T")"1].split(":")"0];
let Minute = Timestamp.split("T")"1].split(":")"1];
let Second = Timestamp.split("T")"1].split(":")"2].split(".")"0];

output = t{Year, Month, Day, Hour, Minute, Second}];

The Results

Contribution by Troy Tessalone

Troy is a Certified Zapier Expert who automates workflows with no-code and low-code apps to help clients save time and make money.