Date format in a javascript parameter

Hi,

Using the modeler I have an input parameter of type script (format javascript).
I get a variable defined as a form input @ the start of the process. I get the variable using execution.getVariable(“mydate”).

How can I format it to ISO format or any other custom format?

Thanks

@steel

If your date is a String then you can parse it and then convert it to a iso date.
If its already a date and then you could do something like myDate.toString()

var myDate = new Date(execution.getVariable('myDate'));
var isoDate = myDate.toISOString();

or if its already a Type Date in camunda

https://docs.oracle.com/javase/7/docs/api/java/util/Date.html#toString()

var myDate = execution.getVariable('myDate');
var stringDate = myDate.toString();
1 Like