Macros in Date, Time, and Datetime Fields

This tutorial explores a set of JetFormBuilder macros designed for working with time and date-based logic. Use macros to perform calculations, comparisons, and dynamic form behaviors based on time intervals.

Where Macros Can Be Used

These macros were created for Date, Time, and Datetime Fields. They can be used in the fields of the Block > Value section by clicking the “wrench” button.

date and time macros in jetformbuilder

Also, macros can be used in the Conditional Logic pop-up of the Conditional Block.

date and time macros in conditional logic

%CT::CurrentDate%

%CT::CurrentDate% returns the current date and time as a Unix timestamp (the number of seconds since January 1, 1970). This macro acts as a replacement for JavaScript’s Date.now() and can be used in dynamic conditions, filters, or calculations where the current moment in time is needed.

NOTE

Always wrap the macro in single quotes.

Example

For the Date Field: use the ‘|toDate’ modifier to display only the date in ‘YYYY-MM-DD’ format:

‘%CT::CurrentDate|toDate%’

Result:

'2022-10-22'

For the Datetime Field: use the ‘|toDateTime’ modifier to display both date and time:

'%CT::CurrentDate|toDateTime%'

Result:

'2022-10-22T17:49'

For the Time Field: use the ‘|toTime’ modifier to display only the time in ‘HH:MM’ format:

'%CT::CurrentDate|toTime%'

Result:

'17:49'

%CT::Min_In_Sec%

It returns the number of milliseconds in one minute. It’s useful for time-based calculations, especially when defining delays, countdowns, or converting minutes into a usable format for scripts, filters, or dynamic logic.

Example

Getting the difference between dates in minutes:

(%some_date_field|T% - %another_date_field|T%) / %CT::Min_In_Sec%

%CT::Hour_In_Sec%

It returns the number of milliseconds in one hour.

Example

Getting the difference between dates in hours:

(%some_date_field|T% - %another_date_field|T%) / %CT::Hour_In_Sec%

%CT::Day_In_Sec%

It returns the number of milliseconds in one day.

Example

Getting the difference between dates in days:

(%some_date_field|T% - %another_date_field|T%) / %CT::Day_In_Sec%

%CT::Month_In_Sec%

It returns the number of milliseconds in one month.

Example

Getting the difference between dates in months:

(%some_date_field|T% - %another_date_field|T%) / %CT::Month_In_Sec%

%CT::Year_In_Sec%

It returns the number of milliseconds in one year.

Example

Getting the difference between dates in years:

(%some_date_field|T% - %another_date_field|T%) / %CT::Year_In_Sec%

That’s all; now you know how to use the date and time-based macros in JetFormBuilder forms on the WordPress website.