Get current date

This script shows you how to get the current date and time to use e. g. for a filename.

/**
 * MyDatamerge Javascript (Examples: https://mydatamerge.com/javascript)
 * This script illustrates on how to get the current date and time
 *
 * REQUIREMENTS:
 * None, you can use this in a script element without any more setup
**/

// Get the date in Y-m-d format
var today = new Date();
var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();

// Get the time in hours-minutes-seconds format
var time = today.getHours() + "-" + today.getMinutes() + "-" + today.getSeconds();

// return String in format  date_time
return date + "_" + time;

Use this code in a Script element. Find more information here