Skip to content

getDayName — GTM Variable Template for Date

VARIABLES › DATE
getDayName CORE Date

Returns the full name of the day of the week. 0 = Monday, 6 = Sunday.


When to Use This

Date Formatting

Format and transform date values into human-readable or machine-readable strings.


Examples

Index 0 returns Monday
INPUT
Day Index: 0
OUTPUT
Monday
Index 6 returns Sunday
INPUT
Day Index: 6
OUTPUT
Sunday

GTM Configuration

This is what you'll see when you open this variable in Google Tag Manager. Hover the icons for details.

getDayName
Day Index
💾 An integer representing the day of the week (0 = Monday, 1 = Tuesday, etc.).

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
getDayFullName()


Under the Hood

📜 View Implementation Code
/**
* Returns the full 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 full name of the day (e.g., "Monday", "Tuesday", etc.), or undefined if the index is invalid.
*
* @framework ggLowCodeGTMKit
*/
const makeNumber = require('makeNumber');

const getDayFullName = function(dayInt) {
   const day = makeNumber(dayInt);
   const dayList = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
   return dayList[day];
};

const safeFunction = fn => typeof fn === 'function' ? fn : x => x;
const out = safeFunction(data.out);

// ===============================================================================
// getDayFullName - Direct mode
// ===============================================================================
const applyCast = (castFn, value) => safeFunction(castFn)(value);
const value = applyCast(data.pre, data.src);
return out(getDayFullName(value));
// ===============================================================================
// getDayFullName() – Apply Mode
// ===============================================================================
/*
return function(value) {
  return out(getDayFullName(value));
};
*/
🧪 View Test Scenarios (4 tests)
✅ '[example] Index 0 returns Monday'
✅ Valid day index 3 - returns Thursday
✅ '[example] Index 6 returns Sunday'
✅ Non valid day index 10 - returns undefined