Wednesday, August 24, 2022

Generate current date or Timestamp in NeoLoad using JavaScript | NeoLoad date variable | Get Date/Time in UTC in JavaScript

If you want to generate current Timestamp in NeoLoad using JavaScript, you can simply write the below code and you can enhance more based on the result. you can add days or months or years.

//Declare the variables

var DateNTime = new Date();
var utcDate = DateNTime.toUTCString();
 
//Print results to NeoLoad log

logger.debug("UTC_Date="+utcDate);

// Inject the computed value in a runtime variable, this can be used as a parameter in the NeoLoad requests ex:${UTC_Date}

context.variableManager.setValue("UTC_Date",utcDate);