getMonthNameShort — GTM Variable Template for Date
getMonthNameShort CORE Date
Returns the abbreviated name of the month. 0 = Jan, 11 = Dec.
When to Use This
Date Formatting
Format and transform date values into human-readable or machine-readable strings.
Examples
Index 0 returns Jan
INPUT
Month Index: 0
OUTPUT
Jan
Index 11 returns Dec
INPUT
Month Index: 11
OUTPUT
Dec
GTM Configuration
This is what you'll see when you open this variable in Google Tag Manager. Hover the icons for details.
getMonthNameShort
Month Index
💾 An integer representing the month of the year (0 = January, 1 = February, etc.).
Supported formats:
✓ Number
✓ String
Supported formats:
✓ Number
✓ String
Input Setup
Input Function (optional)
⚙️ Optional pre-processing function applied to the input before internal logic (e.g., convert object to string, normalize case). Internal transformations such as case handling will still apply afterward.
Result Handling
Output Function (optional)
⚙️ Optional function to apply to the result before returning it (e.g., str => str + ' €', val => val !== undefined for boolean conversion). Useful for chaining transformations on the output.
Month Index number
💡 Type any text to see the result update live
🎯 Using special value — click input to type instead
Test with:
Falsy
Truthy
🔗 Result Handling — Chain Variables
Chain apply-mode variables to the output. Each variable receives the result of the previous one.
getMonthNameShort()
Related Variables
Same category: Date
Under the Hood
📜 View Implementation Code
/**
* Returns the abbreviated name of the month based on the given integer where 0 = January, 1 = February, etc.
*
* @param {number|string} data.src - An integer representing the month of the year (0 to 11).
* @param {Function|string} [data.out] - Optional output handler: function to transform result or string with format.
*
* Direct-mode specific parameters:
* @param {Function} [data.pre] - Optional pre-processor function to transform src before conversion.
*
* @returns {string|undefined} The abbreviated name of the month (e.g., "Jan", "Feb", etc.), or undefined if the index is invalid.
*
* @framework ggLowCodeGTMKit
*/
const makeNumber = require('makeNumber');
const getMonthNameShort = function(monthInt) {
const month = makeNumber(monthInt);
const monthList = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"];
return monthList[month];
};
const safeFunction = fn => typeof fn === 'function' ? fn : x => x;
const out = safeFunction(data.out);
// ===============================================================================
// getMonthNameShort - Direct mode
// ===============================================================================
const applyCast = (castFn, value) => safeFunction(castFn)(value);
const value = applyCast(data.pre, data.src);
return out(getMonthNameShort(value));
// ===============================================================================
// getMonthNameShort() – Apply Mode
// ===============================================================================
/*
return function(value) {
return out(getMonthNameShort(value));
};
*/🧪 View Test Scenarios (4 tests)
✅ '[example] Index 0 returns Jan'
✅ Valid month index 5 - returns June
✅ '[example] Index 11 returns Dec'
✅ Invalid month index - returns undefined