Information:

Environment

  • Dynatrace Recorder

 

 

Solution

Use Javascript functions in a Custom action to obtain the date and format the date as needed.

Below is a sample script that pulls in different parts of a date, and formats them in the format:
MM/DD/YYYY HH:MM:SS

var now = new Date(); // gets current date
var MM = now.getMonth()+1; // gets month (+1 is needed because month is zero based)
var DD = now.getDate(); // gets day of the month
var YYYY = now.getFullYear(); // gets the year
var HH = now.getHours();
var NN = now.getMinutes();
var SS = now.getSeconds();

var slash = "/";
var colon = ":";

var formattedDate = MM + slash + DD + slash + YYYY + " " + HH + colon + NN + colon + SS;

No special libraries are needed when working with dates... just some basic knowledge of how the date function works.

For more information, see Using Dynamic Dates in the documentation.

 

 

 

 

  • No labels