isUnixTimestampMilliseconds β GTM Variable Template for Logic
isUnixTimestampMilliseconds EXTENDED Logic
Check if the input is a valid Unix timestamp in milliseconds format.
When to Use This
Section titled βWhen to Use ThisβExamples
Section titled βExamplesβValid ms timestamp
INPUT
Value To Check: 1609459200000
OUTPUT
true
Zero returns false
INPUT
Value To Check: 0
OUTPUT
false
Live Sandbox
Section titled βLive SandboxβThis is what you'll see when you open this variable in Google Tag Manager. Hover the icons for details.
isUnixTimestampMilliseconds
Value To Check
πΎ The value to check.
Supported formats:
β All
Supported formats:
β All
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.
Value To Check 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.
isUnixTimestampMilliseconds()
Related Variables
Section titled βRelated VariablesβSame category: Logic
Under the Hood
Section titled βUnder the Hoodβπ View Implementation Code
/** * Checks if the provided input is a valid Unix timestamp in milliseconds format. * * @param {any} data.src - The input value to check (could be a string or number). * @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 checking. * * @returns {boolean} True if the input is a valid Unix timestamp in milliseconds format, false otherwise. * * @framework ggLowCodeGTMKit */const makeInteger = require('makeInteger');const makeNumber = require('makeNumber');const isUnixTimestampMilliseconds = function(value) { if (value === null || value === "") { return false;} const valueNum = makeNumber(value); const valueInt = makeInteger(value); if (typeof valueInt === 'number' && valueNum === valueInt) { return valueInt >= 1000000000000 && valueInt <= 8640000000000; // Valid range for milliseconds } return false;};const safeFunction = fn => typeof fn === 'function' ? fn : x => x;const out = safeFunction(data.out);// ===============================================================================// isUnixTimestampMilliseconds - Direct mode// ===============================================================================const applyCast = (castFn, value) => safeFunction(castFn)(value);const value = applyCast(data.pre, data.src);return out(isUnixTimestampMilliseconds(value));// ===============================================================================// isUnixTimestampMilliseconds() β Apply Mode// ===============================================================================/*return function(value) { return out(isUnixTimestampMilliseconds(value));};*/π§ͺ View Test Scenarios (6 tests)
β
'[example] Valid ms timestamp'β
String timestamp - should return trueβ
Decimal timestamp - should return falseβ
Too large timestamp - should return falseβ
'[example] Zero returns false'β
Empty String - should return false