Skip to content
  • There are no suggestions because the search field is empty.

Add DateTime or Timestamp

Reference on working with datetimes and timestamps

Why:

The built-in evaluates in ISO8601 format which has characters that may not be desired or not be supported for filename use by the host operating system (e.g. ':' not supported in filenames on Windows OS)

Results in:

Example 1: Assign a unique value to a filename output

Example file output:
 
 
Use a pipeline to populate the metadata with the desired date format:
 
 
Transform - "SetMetadataDateTime"
//assign the built-in system date object
const date = System.Internal.DateTime;

//call method for the ISO string
const filenameSafeDateTimeISO = date.toISOString().replace(/[:.-]/g, "_");

//call method for the Unix timestamp value
const filenameSafeDateTimeUnix = date.getTime();

//assign values to metadata
stage.setMetadata("dt_iso",filenameSafeDateTimeISO); 
stage.setMetadata("dt_unix",filenameSafeDateTimeUnix);
Write New - "WriteToFile"
 

Notes:

Using the reference directly in the File Name of the File Output is not supported.
 
Results in: