Hello @supratim320 ,
i thought Date can parse date in any format but somehow DD-MM-YYYY is not one the formats it accepts. Same goes for the JSAPI function parseDateTime it accepts only ISO 8601 date strings.
You can still do a simple mapping:
var dateString = '05-04-2023 10:30:00',
parts = dateString.split(' '),
dateParts = parts[0].split('-'),
timeParts = parts[1].split(':'),
year = parseInt(dateParts[2], 10),
month = parseInt(dateParts[1], 10) - 1,
day = parseInt(dateParts[0], 10),
hours = parseInt(timeParts[0], 10),
minutes = parseInt(timeParts[1], 10),
seconds = parseInt(timeParts[2], 10),
date = new Date(year, month, day, hours, minutes, seconds);
logInfo(date);
var df = formatDate(date,"%4Y-%2M-%2D %02H:%02N:%02S");
logInfo(df);
//04/05/2023 4:39:10 AM js 2023-04-05 10:30:00
//04/05/2023 4:39:10 AM js Wed Apr 05 2023 10:30:00 GMT-0400 (EDT)
Although I would recommend sending already preformatted date in ISO 8601, from the source system if it is possible
Marcel Szimonisz