Skip to main content
Question

In workflow javascript. New date() return "wrong" date/time.

  • March 25, 2026
  • 2 replies
  • 31 views

Forum|alt.badge.img+14

Hi all,

In a workflow javascript I am using “new date()” to find the current date and time:

var NowDK_ = new Date();

execution.setVariable("NowDK_ ", NowDK_ );

If returns something like 

"2026-03-25T09:27:14.560+0000"

That is 1 hour behind the database server (sysdate) and application server.

How do I get the the “right” date(like sysdate) inside a workflow?

2 replies

Forum|alt.badge.img+5
  • Do Gooder (Employee)
  • March 25, 2026

Hi ​@Hans Andersen 

try this

var currDate = new Date();
var isoDate = currDate.toISOString();
var formattedDate = isoDate .replaceAll('T', '-').replaceAll(':','.').slice(0, -5);
execution.setVariable(' formattedDate', formattedDate); 

 


Forum|alt.badge.img+5
  • Do Gooder (Employee)
  • March 25, 2026

Hi,

Adding to the above, currently the BPA workflow engine supports the following DATETIME formats:

  • yyyy-MM-dd-HH.mm.ss (2023-09-21-07.04.39)
  • yyyy-MM-dd-HH.mm.ss.SSSSSSS (2023-09-22-08.04.39.0000000)

https://docs.ifs.com/techdocs/24r2/040_tailoring/500_business_process_automation/250_workflow_faq/

You can also use the following JavaScript to convert dates and timestamps to support the BPA workflow engine:

 

var cNow = new Date();
var cToday = cNow.toLocaleDateString();
execution.setVariable("EffectiveDate", cToday );

 

-------------------------------------------------------------------------------------------------------------------------------------------------
var SimpleDateFormat = Java.type("java.text.SimpleDateFormat");
var Date = Java.type("java.util.Date");
var currentDate = new Date();
var sdf = new SimpleDateFormat("yyyy-MM-dd-HH.mm.ss");
var formattedDate = sdf.format(currentDate);
execution.setVariable("Cf_Pcx_Datetime", formattedDate);

 


var now = new Date();
var isoString = now.toISOString();
var datePart = isoString.substring(0, 10);
var timePart = isoString.substring(11, 19).replace(/:/g, '.');
var datetime = datePart + '-' + timePart ;
execution.setVariable("Pcx_Datetime", datetime );