getMonthName — GTM Variable Template for Date
getMonthName CORE Date
Returns the full name of the month. 0 = January, 11 = December.
When to Use This
Date Formatting
Format and transform date values into human-readable or machine-readable strings.
Examples
Index 0 returns January
INPUT
Month Index: 0
OUTPUT
January
Index 11 returns December
INPUT
Month Index: 11
OUTPUT
December
Invalid index returns undefined
INPUT
Month Index: 12
OUTPUT
undefined
GTM Configuration
This is what you'll see when you open this variable in Google Tag Manager. Hover the icons for details.
getMonthName
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.
getMonthFullName()
Related Variables
Same category: Date
Under the Hood
📜 View Implementation Code
/**
* Returns the full 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 full name of the month (e.g., "January", "February", etc.), or undefined if the index is invalid.
*
* @framework ggLowCodeGTMKit
*/
const makeNumber = require('makeNumber');
const getMonthFullName = function(monthInt) {
const month = makeNumber(monthInt);
const monthList = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
return monthList[month];
};
const safeFunction = fn => typeof fn === 'function' ? fn : x => x;
const out = safeFunction(data.out);
// ===============================================================================
// getMonthFullName - Direct mode
// ===============================================================================
const applyCast = (castFn, value) => safeFunction(castFn)(value);
const value = applyCast(data.pre, data.src);
return out(getMonthFullName(value));
// ===============================================================================
// getMonthFullName() – Apply Mode
// ===============================================================================
/*
return function(value) {
return out(getMonthFullName(value));
};
*/🧪 View Test Scenarios (5 tests)
✅ '[example] Index 0 returns January'
✅ '[example] Index 11 returns December'
✅ String number month index - converts and returns month name
✅ '[example] Invalid index returns undefined'
✅ Invalid string input - returns undefined