Add Seconds
The addSeconds function adjusts a given date by a specified number of seconds, using positive values to increment and negative values to decrement.
Syntax
{%= addSeconds(date, number) %}
Example
- Input:
{%= addSeconds(stringToDate("2024-11-01T17:19:51Z"),10) %} - Output:
2024-11-01T17:20:01Z
Add Years
The addYears function adjusts a given date by a specified number of years, using positive values to increment and negative values to decrement.
Syntax
{%= addYears(date, number) %}
Example
- Input:
{%= addYears(stringToDate("2024-11-01T17:19:51Z"),2) %} - Output:
2026-11-01T17:19:51Z
Age
The age function is used to retrieve the age from a given date.
Syntax
{%= age(datetime) %}
Age In Days
The ageInDays function calculates the age of a given date in days, i.e. the number of days elapsed between the given date and the current date, negative for future dates and positive for past dates.
Syntax
{%= ageInDays(date) %}
Example
currentDate = 2025-01-07T12:17:10.720122+05:30 (Asia/Kolkata)
- Input:
{%= ageInDays(stringToDate("2025-01-01T17:19:51Z"))%} - Output:
5
Age In Months
The ageInMonths function calculates the age of a given date in months, i.e. the number of months elapsed between the given date and the current date , negative for future dates and positive for past dates.
Syntax
{%= ageInMonths(date) %}
Example
currentDate = 2025-01-07T12:22:46.993748+05:30(Asia/Kolkata)
- Input:
{%=ageInMonths(stringToDate("2024-01-01T00:00:00Z"))%} - Output:
12
Compare Dates
The compareDates function compares the first input date with the other. Returns 0 if date1 is equal to date2, -1 if date1 comes before date2 and 1 if date1 comes after date2.
Syntax
{%= compareDates(date1, date2) %}
Example
- Input:
{%=compareDates(stringToDate("2024-12-02T00:00:00Z"), stringToDate("2024-12-03T00:00:00Z"))%} - Output:
-1
Convert ZonedDateTime
The convertZonedDateTime function converts a date-time to a given timezone.
Syntax
{%= convertZonedDateTime(dateTime, timezone) %}
Example
- Input:
{%=convertZonedDateTime(stringToDate("2019-02-19T08:09:00Z"), "Asia/Tehran")%} - Output:
2019-02-19T11:39+03:30[Asia/Tehran]
Current time in milliseconds
The currentTimeInMillis function is used to retrieve current time in epoch milliseconds.
Syntax
{%= currentTimeInMillis() %}
Date difference
The dateDiff function is used to retrieve the difference between two dates in number of days.
Syntax
{%= dateDiff(datetime,datetime) %}
Day of month
The dayOfMonth returns the number representing the day of the month.
Syntax
{%= dayOfMonth(datetime) %}
Example
- Input:
{%= dayOfMonth(stringToDate("2024-11-05T17:19:51Z")) %} - Output:
5
Day of week
The dayOfWeek function is used to retrieve the day of week.
Syntax
{%= dayOfWeek(datetime) %}
Day of year
The dayOfYear function is used to retrieve the day of year.
Syntax
{%= dayOfYear(datetime) %}
Diff In Seconds
The diffInSeconds function returns the difference between two dates in terms of seconds.
Syntax
{%= diffInSeconds(endDate, startDate) %}
Example
- Input:
{%=diffInSeconds(stringToDate("2024-11-01T17:19:51Z"), stringToDate("2024-11-01T17:19:01Z"))%} - Output:
50
Extract Hours
The extractHours function extracts the hour component from a given timestamp.
Syntax
{%= extractHours(date) %}
Example
- Input:
{%= extractHours(stringToDate("2024-11-01T17:19:51Z"))%} - Output:
17
Extract Minutes
The extractMinutes function extracts the minute component from a given timestamp.
Syntax
{%= extractMinutes(date) %}
Example
- Input:
{%= extractMinutes(stringToDate("2024-11-01T17:19:51Z"))%} - Output:
19
Extract Months
The extractMonth function extracts the month component from a given timestamp.
Syntax
{%= extractMonths(date) %}
Example
- Input:
{%=extractMonth(stringToDate("2024-11-01T17:19:51Z"))%} - Output:
11
Extract Seconds
The extractSeconds function extracts the second component from a given timestamp.
Syntax
{%= extractSeconds(date) %}
Example
- Input:
{%=extractSeconds(stringToDate("2024-11-01T17:19:51Z"))%} - Output:
51