Reputation: 111
I try to write this code to pass in a time and format it. It works on my IDE but when I pass it to zapier, it has an error. This is my code
function dateConvert(dateobj,format){
var year = dateobj.getFullYear();
var month= ("0" + (dateobj.getMonth()+1)).slice(-2);
var date = ("0" + dateobj.getDate()).slice(-2);
var hours = ("0" + dateobj.getHours()).slice(-2);
var minutes = ("0" + dateobj.getMinutes()).slice(-2);
var seconds = ("0" + dateobj.getSeconds()).slice(-2);
var day = dateobj.getDay();
var months = ["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"];
var dates = ["SUN","MON","TUE","WED","THU","FRI","SAT"];
var converted_date = "";
switch(format){
case "YYYY-MM-DD":
converted_date = year + "-" + month + "-" + date;
break;
case "YYYY-MMM-DD DDD":
converted_date = year + "-" + months[parseInt(month)-1] + "-" + date + " " + dates[parseInt(day)];
break;
}
return converted_date;
}
var date = input.VIP_2bParsed;
var format = "YYYY-MMM-DD DDD";
var converted_day = dateConvert(date,format);
output={converted_day: converted_day}
I have the following error: TypeError: dateobj.getFullYear is not a function Full image of error here ERROR
Upvotes: 1
Views: 424
Reputation: 543
Is VIP_2bParsed
a variable you mapped in the Zap editor? If so, you'll want to access it with inputData.VIP_2bParsed
instead of input.VIP_2bParsed
.
Upvotes: 1