Gravity Forms Date Time Calculator
Use Date and Time fields in your Gravity Forms calculations. Perform advanced date and time calculation with ease.
What does it do?
This plugin adds the ability to use Date and Time fields in Gravity Forms calculations. Create complex and precise calculations based on any combination of Date, Time, and Number fields. Calculations can be used in any field that normally supports calculations, allowing you to build forms with flexible time-based pricing, track days and hours, determine the age of a customer based on their birth date, and any other calculation related to date and time.
Features
- Use Date and Time fields in your Gravity Forms’ calculations.
Create robust date and time-based calculations right in your form editor. - Calculate duration between dates and times.
Determine how many years, days, hours (and more!) are between any two Date or Time fields. - Supports every date/time unit you’ll need.
Get your results in years, months, weeks, days, hours, minutes and seconds. - Calculate the user’s age and apply age-specific customizations.
Prevent underage submissions, configure child/senior pricing, determine customer’s age for past and future milestones. - Count weekdays and weekend days between two dates.
Only count the days that are important for your calculation. - Duration-based pricing.
Combine with Gravity Forms Calculated Product fields to create dynamic pricing based on user selected dates/times. - Automatic updates.
Get updates and the latest features right in your dashboard. - Awesome support.
We’re here to help! And we mean it.
Documentation
How do I enable this functionality?
After installing and activating Gravity Forms Date Time Calculator, calculations based on Date and Time fields become available in Number fields within your form. Let’s step through that process.
![]() |
Add two Date or Time fields to your form. |
![]() |
Add a Number field to your form and check Enable Calculation. |
![]() |
Insert Date or Time field merge tags into your calculation. |
Now that you know how to create Date-based calculations, let’s dig into the specifics of what Date Time Calculator can do.
Feature Details
Field Settings
Merge Tags
In fields that support calculations, like Number and Product fields, the Insert Merge Tag drop down is automatically populated with any Date or Time fields in the form.
Rounding
Date Time Calculator fully supports Gravity Forms Rounding. If you are looking to round by increments, we have an awesome snippet called Rounding by Increments with Gravity Forms. Super helpful when trying to round up, down or setting a min/max.
Date Calculation Unit
Set the calculation unit for the current field. Use this to change the value output on the front end. This also affects how things are calculated on the back end, which is especially useful when working with modifier fields.
Date Based Calculations
Dates are calculated just like any Number. Insert the merge tags for the Date fields into the Formula box with mathematical operators and it will take care of the rest. To count the number of days between two Date fields, simply subtract one field from the other.
Always subtract the oldest date from the most recent date or you might end up with a negative number due to the way Date Time Calculator processes date fields.
Counting Weekdays or Weekend Days
Use the {weekdays:}
and {weekendDays:}
merge tags to count the number of weekdays or weekend days between two
dates. Use the following syntax:
{weekdays:{FIELD_LABEL:FIELD_ID},{FIELD_LABEL_:FIELD_ID}}
For example, if we have two date fields labeled “Start Date” and “End Date” with Field IDs of 1 and 2 respectively, use the following merge tag to count the number of weekdays between the two dates.
{weekdays:{Start Date:1},{End Date:2}}
Weekday and weekend day counts include the first day. To exclude it, simply add a -1
to your calculation after the
merge tag.
Time Based Calculations
Calculations between Time fields behaves mostly the same as Date fields. Insert the merge tags into a Number field and Date Time Calculator will perform any mathematical operations you tell it to.
Combined Calculations
You can combine Date and Time fields to create combined calculations. This lets you create more precise calculations all the way down to the second. In the following example, we’ll count the number of hours between two dates with specific times.
- Start by adding two Date and two Time fields to your form. Name them Start Date, End Date, Start Time, and End Time.
Add a Number field to your form, Enable Calculation, and try to remember your mathematical order of operations when entering your formula.
Set the Date Calculation Unit to “Hours”.
User Modified Calculations
Date Time Calculator supports user modified date calculations by including additional Number fields in the calculation. In the following example, we’ll count the number of days between two dates and add a user-defined amount of days to the result.
- Start with two Date fields and a Number field in your form, matching the same setup in the Date Based Calculation above.
- Add an additional Number field to the form. Name it Modifier.
Add the merge tag for the Modifier field to the calculation in your result field.
{Date:2} - {Date:1} + {Modifier:4}
On the front end, the user can select the Start and End Dates, input a modifier in the Modifier field, and the result will add the number of days in the Modifier field to the result.
To automatically modify dates without user input, simply add the number directly in the calculation.
Calculating Age
Calculating age is simple with Date Time Calculator. To calculate age from a Date field, add the :age merge tag modifier to the desired Date field merge tag using the following template:
{FIELD_LABEL:FIELD_ID:age}
For example, for a field labeled “Date of Birth” with a field ID of “1”, the merge tag is written like this:
{Date of Birth:1:age}
Current Date and Time Calculations
Use the {today}
merge tag to make calculations based on the current date. For example, to count the number of days
between now and a user-inputted date, use the following syntax:
{Date:1} - {today}
The same can be done with Time fields and the {now}
merge tag.
{Time:1} - {now}
Both of these merge tags are automatically recalculated on submission to maintain accuracy. If your form relies on up-to-the-second time, we have you covered.
Integrations
Gravity Forms Advanced Calculations
Date Time Calculator integrates seamlessly with Gravity Forms Advanced Calculations. GP Advanced Calculations allows for complex functions, formulas, conditionals, and more directly in your Number and Product fields. These two perks can also be used together to calculate durations.
Translations
You can use the free Loco Translate plugin to create translations for any of our Perks. If you’ve never used Loco translate before, here’s a tutorial written for beginners.
FAQs
Can I disable autocomplete for Date fields?
Use this snippet to disable autocomplete for your forms.
How do I calculate between Daylight Savings and Standard Times?
If you’re calculating the difference between a day in Daylight Savings Time and a day in Standard Time, a whole number will not be returned since there is a missing or extra hour in the calculation.
To return a whole number, set the Rounding setting to 0 on your Number field.
Known Limitations
When using any Date Time Calculator merge tags, the Validate Formula button may display a message stating that the formula is invalid.
We recommend using GP Advanced Calculations – it offers a more robust functionality for calculating and validating formulas.
Hooks
- gpdtc_add_delta_warning_entry_note
- gpdtc_delta_warning_email_recipient
- gpdtc_send_delta_warning_admin_email
- gpdtc_warning_max_delta
Gravity Forms has hundreds of hooks. Check out our Gravity Forms Hook Reference for the most thorough guide to Gravity Forms’ many actions and filters.
Related Resources
- 6 Examples of the Best Gravity Forms Add-Ons and Extensions
Use Gravity Perks to create all sorts of neat Gravity Forms examples on your WordPress website in just a few simple steps. - 6 Tips to Perfect Your Gravity Forms Datepicker
Supercharge the Gravity Forms Datepicker with linked fields, improved mobile experience, and more! - Calculate Age with Gravity Forms
Accurately calculate a customer's age based on their date of birth. - Calculate the Number of Days Between Two Dates With Gravity Forms
Calculate the number of days between two given date fields and populate this number into a field on the form. - How to Build a Player Roster with Age-Based Pricing
Register players with age-based registration fees in a single form submission. - How to Calculate in Both Years and Months with Gravity Forms
Learn how to use Gravity Forms to calculate in both years and months for countdowns, job histories, exact ages, or anything else. - How to Create Timesheets with Gravity Forms
Learn how to take timesheets and time tracking to the next level using Nested Forms and Date Time Calculator. Plus, calculate overtime pay, restrict entries to available weekdays only, and other tips. - How to Set Up Age Based Pricing
Adjust a product's price based on the customer's calculated age. - Using Gravity Forms for Age Verification: How to set up Age-based Validation
Often used for adult products (like alcohol) or concert tickets, age verification forms can prevent form submissions if the user's age is below or above a specified threshold.