Inserting month name instead of month number

I have an action that inserts a date time string at the end of a line, for use in a log, cobbled together from a couple of actions in the directory. The variables below create the string. The variable “day” inserts “Mon, Tue, Wed” etc.

// Insert day dd-mm-yyyy hh:min
var now = new Date();
var hh = now.getHours();
var min = now.getMinutes();
var dd = now.getDate();
var mm = now.getMonth()+1;
var yyyy = now.getYear()+1900;
var dayOfWeek = now.getDay();
var daysOfWeek = new Array(“Sun”, “Mon”, “Tue”, “Wed”, “Thu”, “Fri”, “Sat”)
var day = daysOfWeek[dayOfWeek];

Is it possible, using something similar, to insert the month name (“Jan, Feb” etc) instead of the 2 digit number? So the inserted string would look like Tue 01-Jan-2020 09:14.
I can link to the actual action if necessary. Thanks.

It’s a lot easier using the strftime function.

like:

const now = new Date();
let dateStr = strftime(now, "%a  %d-%b-%Y %h:%m");
1 Like