Returning Date or Time in double digits

You can force a leading 0 to be present where needed on date time parts via JavaScript.

An example getting the current month and returning to a CallScripter Field/Variable called "monthNumber":

var currentDate = new Date();
var month = currentDate.getUTCMonth() + 1;
[monthNumber] = month;




This can be used for a complete date time formatted string to ensure format compliance:

var currentDate = new Date();
var year = currentDate.getFullYear();
var month = currentDate.getMonth() + 1;
if(month < 10) month = "0" + month;
var day = currentDate.getDate();
if(day < 10) day = "0" + day;
var hours = currentDate.getHours();
if(hours < 10) hours = "0" + hours;
var minutes = currentDate.getMinutes();
if(minutes < 10) minutes = "0" + minutes;
var seconds = currentDate.getSeconds();
if(seconds < 10) seconds = "0" + seconds;
[callDate] = year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;