getDayNameShort — GTM Variable Template for Date
getDayNameShort CORE Date
Returns the abbreviated name of the day of the week. 0 = Mon, 6 = Sun.
When to Use This
Date Formatting
Format and transform date values into human-readable or machine-readable strings.
Examples
Index 0 returns Mon
INPUT
Day Index: 0
OUTPUT
Mon
Invalid index returns undefined
INPUT
Day Index: 10
OUTPUT
undefined
GTM Configuration
This is what you'll see when you open this variable in Google Tag Manager. Hover the icons for details.
getDayNameShort
Day Index
💾 An integer representing the day of the week (0 = Monday, 1 = Tuesday, 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.
Day 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.
getDayName()
Related Variables
Same category: Date
Under the Hood
📜 View Implementation Code
/**
* Returns the abbreviated name of the day of the week based on the given integer where 0 = Monday, 1 = Tuesday, etc.
*
* @param {number|string} data.src - An integer representing the day of the week (0 to 6).
* @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 day (e.g., "Mon", "Tues", etc.), or undefined if the index is invalid.
*
* @framework ggLowCodeGTMKit
*/
const makeNumber = require('makeNumber');
const getDayName = function(dayInt) {
const day = makeNumber(dayInt);
const dayList = ["Mon", "Tues", "Wed", "Thu", "Fri", "Sat", "Sun"];
return dayList[day];
};
const safeFunction = fn => typeof fn === 'function' ? fn : x => x;
const out = safeFunction(data.out);
// ===============================================================================
// getDayName - Direct mode
// ===============================================================================
const applyCast = (castFn, value) => safeFunction(castFn)(value);
const value = applyCast(data.pre, data.src);
return out(getDayName(value));
// ===============================================================================
// getDayName() – Apply Mode: runtime parameter
// ===============================================================================
/*
return function(value) {
return out(getDayName(value));
};
*/🧪 View Test Scenarios (4 tests)
✅ '[example] Index 0 returns Mon'
✅ Valid day index 3 - returns Thursday
✅ Valid day index 6 - returns Sunday
✅ '[example] Invalid index returns undefined'