We're using the "Execute Javascript code" to capture date/time information and it is returning output similar to: undefined-2021-07-16-undefined 10:44:12
While using the following javascript code:
var d = new Date();
var minutesToAdd=0;
var futureDate = new Date(d.getTime() + minutesToAdd*60000);
var localtime = futureDate.toLocaleTimeString('en-US', { hour12: false});
var newDate = new Date();
var myTime = new Date(newDate.getTime());
var myMMDDYYY = myTime.toLocaleDateString('en-US', { year: 'numeric', month: '2-digit', day: '2-digit' });
var chunks = myMMDDYYY.split("/");
var theDateFormatted = chunks[1]+'-'+chunks[2]+'-'+chunks[0];
output1 = theDateFormatted + ' ' + localtime;
Release : 6.7
Component : CA RELEASE AUTOMATION ACTION PACK
The problem is in the "chunks" statement because there are no forward slashes in the myMMDDYYY variable.
Dates and timestamps are frequently used in various places. The "Execute Javascript code" is frequently used to get date information because the data can be manipulated as desired. To fix the problem for this issue, change the line: var chunks = myMMDDYYY.split("/");
to: var chunks = myMMDDYYY.split("-");
However, something else to consider... there is a "Get Current Date and Time" action that will offer output fields for: