This plugin is part of Gravity Perks, a suite of 31+ essential Gravity Forms addons with support you can count on.

## 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 been 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.**Passionate Support**

We’re here to help! And we mean it.

## Documentation

- How do I enable this functionality?
- Feature Details
- Date Based Calculations
- Counting Weekdays or Weekend Days
- Time Based Calculations
- Combined Calculations
- User Modified Calculations
- Calculating Age
- Current Date and Time Calculations
- FAQs
- Hooks
- How To

### 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.

###### 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.

### 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}}`

`-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.

### 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.

### FAQs

#### Can I disable autocomplete for Date fields?

Use this snippet to disable autocomplete for your forms.

### Hooks

- gpdtc_add_delta_warning_entry_note
- gpdtc_delta_warning_email_recipient
- gpdtc_send_delta_warning_admin_email
- gpdtc_warning_max_delta