JEXL Functions: Date And Time
Function Reference
This section lists the non-entity JEXL helper functions currently available in tSM configuration. Entity calls such as crm.customer.find(...) are covered separately in the Public API section.
Date & Time
addTime(date, amount, unit)
Adds time to a date and returns an ISO string with local timezone offset.
Supported units: 'years', 'months', 'days', 'hours', 'minutes', 'seconds'.
addTime('2026-05-09T10:00:00.000Z', 2, 'days')
// '2026-05-11T12:00:00+02:00' depending on runtime timezone
Form usage:
addTime($context.form.validFrom, 30, 'days')
If amount is not a number, the date is invalid, or the unit is not supported, the function returns null.
addTimeIso(date, amount, unit)
Adds time to a date and returns a UTC ISO string ending with Z.
addTimeIso('2026-05-09T10:00:00.000Z', 1, 'hours')
// '2026-05-09T11:00:00.000Z'
Use this when the backend or API expects UTC ISO values.
toIso(date)
Converts a Date or parseable date string to an ISO string using new Date(date).toISOString().
toIso($context.form.installationDate)
Invalid dates can throw Invalid time value, so validate or guard the input first.
now(withoutTime = false)
Returns the current date and time as an ISO string.
now()
Without time:
now(true)
// today's date with time set to 00:00:00.000 in local runtime, returned as ISO
nowWithHours(hours, minutes = 0, seconds = 0, formatIso = false)
Creates today's date with a specific time.
nowWithHours(9, 30, 0, true)
// today at 09:30:00 as an ISO string
If formatIso is not true, the function returns a Date object.
isToday(date)
Returns true when the date is today.
isToday($context.form.createdAt)
isTomorrow(date)
Returns true when the date is tomorrow.
isTomorrow($context.form.plannedDate)
isYesterday(date)
Returns true when the date is yesterday.
isYesterday($context.form.reportedAt)
dateFormat(date, format)
Formats a date. The common patterns YYYY and DD are normalized to yyyy and dd, so older examples using YYYY-MM-DD still work.
dateFormat($context.form.validFrom, 'dd.MM.yyyy')
// '09.05.2026'
dateFormat($context.form.validFrom, 'YYYY-MM-DD')
// '2026-05-09'
If the input is null or an empty string, it returns null.
dateFormatFrom(date, fromFormat, toFormat)
Formats a date into the target format. In normal usage, the most important parameter is toFormat, which controls the output.
dateFormatFrom('2026-05-09T00:00:00.000Z', 'YYYY-MM-DD', 'dd.MM.yyyy')
// '09.05.2026'
dateDiff(firstDate, secondDate, unit = 'days', precision = false)
Returns the difference between two dates.
Supported units: 'years', 'months', 'days', 'hours', 'minutes', 'seconds'.
dateDiff('2026-05-10T00:00:00.000Z', '2026-05-09T00:00:00.000Z', 'days')
// 1
Precise decimal difference:
dateDiff('2026-05-09T12:00:00.000Z', '2026-05-09T00:00:00.000Z', 'days', true)
// 0.5
If either date is missing, it returns 0.
datePlusWorkdays(date, daysCount)
Adds a number of working days to a date.
datePlusWorkdays($context.form.requestedDate, 5)
Use it when a due date or planned date must move by business days instead of calendar days.
compareDates(firstDate, secondDate, operator, unit)
Compares two dates after rounding them to the given unit.
Supported operators: '>', '>=', '<', '<='.
compareDates($context.form.validTo, now(), '>=', 'days')
Practical custom validation: validity date is in the past.
compareDates($context.form.validTo, now(), '<', 'days')
minutes(date)
Returns minutes since Unix epoch.
minutes('1970-01-01T01:00:00.000Z')
// 60
Useful for simple numeric date comparisons.
hours(date)
This helper returns 6-minute intervals since Unix epoch, not classic hours. Treat this as a legacy helper with a misleading name.
hours('1970-01-01T01:00:00.000Z')
// 10
If you need a true difference in hours between two dates, use dateDiff(..., 'hours').
midnight(days = 0)
Despite the name, it returns end of day (23:59:59.999) for today plus the day offset.
midnight()
// today at 23:59:59.999 as ISO
midnight(1)
// tomorrow at 23:59:59.999 as ISO
nidToDate(nid)
Tries to derive a birth date from a Czech/Slovak national identification number.
nidToDate('010101/1234')
// for example '2001-01-01', if the value is valid
If the input is invalid, it returns null.
nidValid(nid)
Validates Czech/Slovak national identification numbers, including date, month offsets, and checksum.
nidValid($value)
In validation:
$value && !nidValid($value)
An empty string is considered valid (true). Required-field logic must be handled separately.
roundDateTo(date, unit)
Rounds a date to the selected unit. It is also useful before comparing dates at day or hour precision.
roundDateTo($context.form.date, 'days')
If direct use is not available in a specific field, use compareDates for date comparisons.
seconds(date)
Converts a date to seconds since Unix epoch.
seconds('1970-01-01T00:01:00.000Z')
// 60
If the helper is not available in a specific runtime, use dateDiff or minutes depending on the use case.
decimalToHoursMinutesSeconds(decimalHours)
Converts decimal hours into HH:MM.
decimalToHoursMinutesSeconds(1.5)
// '01:30'
decimalToHoursMinutesSeconds(10.05)
// '10:03'
For null, undefined, or 0, it returns null.
Legacy Compatibility
dateServerFormat(date, time, format)
Deprecated compatibility helper for older configuration. It formats a date with a supplied time value and format.
dateServerFormat($context.form.validFrom, '12:00', 'YYYY-MM-DD')
Prefer newer helpers in new configuration:
| Need | Recommended helper |
|---|---|
| Display date in a UI-friendly format | dateFormat(date, 'dd.MM.yyyy') |
| UTC ISO string from a date value | toIso(date) |
| Keep existing ISO strings unchanged | toISOString(value) |
| Add a relative date/time offset and return UTC ISO | addTimeIso(date, amount, unit) |
| Complex start/end-of-day API parameters | Backend script or API-specific logic |
Keep existing dateServerFormat(...) expressions only when maintaining older configuration. Do not use it for new form fields.