Time to upgrade! You only have until October 31, 2019 to move to Dynatrace, our all-in-one software intelligence platform. For details, see the Synthetic Upgrade Center and Dynatrace Synthetic documentation.

Converting numeric month to its name

This function converts the numeric month to its actual name, for example, converting "month 1" to February (remember this is zero based in JavaScript).

function getShortMonth(date){
var monthShortNames = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ];
return monthShortNames[date.getMonth()];
}

The code can be useful for setting form field values that require the name of the month rather than the numeric value.

A sample usage of the function might look like the following. it just gets the current date and alerting the name of the month.

var now = new Date();
alert (getShortMonth(now));