Gravity Wiz

Magically enhanced tutorials, snippets and plugins for Gravity Forms!

  • Gravity Perks
    • Gravity Perks
    • Tutorials & Snippets
    • About
  • Support
    • Documentation
    • Support
    • Account

Gravity Forms Conditional Logic Dates

Use Date and Time fields in your Gravity Forms conditional logic to make anything conditional based on dates and time.

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

  • View All Perks
  • Buy Gravity Perks

What does it do?

Gravity Forms Conditional Logic Dates adds support for evaluating conditional logic based on dates and times. It can be used to show or hide fields based on user-input dates and times, the current date and time, and even relative dates. Special merge tags and wildcards give you flexible options to precisely trigger conditional logic. Show different fields based on when a user is filling out the form, automatically adjust seasonal pricing, or send a different Notification for after-hours submissions.

Features

  • Show and hide fields based on Date and Time field values.
    Display different fields based on user input.
  • Supports static dates, current date, and relative dates.
    Flexible conditional logic to meet your form’s unique needs.
  • Date wildcards.
    Target a specific day of the month, specific month of the year, or specific year.
  • Day of the week merge tags.
    Trigger conditional logic based on weekdays, weekends, or any combination.
  • Current time logic.
    Show and hide fields based on the current time.
  • Full Gravity Forms integration.
    Use date-based and time-based conditional logic in Confirmations, Notifications, or any Feed.
  • Integrates with Gravity Forms Conditional Pricing.
    Use date-based conditional logic to adjust product pricing.
  • Automatic updates.
    Get updates and the latest features right in your dashboard.
  • Awesome support.
    We’re here to help! And we mean it.

Documentation

  1. How do I enable this functionality?
  2. Feature Details
    1. Date-Based Logic
    2. Static Dates
    3. Relative Dates
      1. User Input
      2. Current Date
    4. Days of the Week
      1. Weekend or Weekday
    5. Date Wildcards
    6. Time-Based Logic
      1. Static Times
      2. Current Time
  3. Hooks
  4. Related Articles

How do I enable this functionality?

After installing and activating Gravity Forms Conditional Logic Dates, Date and Time fields can be selected when creating conditional logic rules for your fields(and other places conditional logic is supported). It integrates seamlessly with Gravity Forms’ existing conditional logic UI.

After selecting a Date or Time field, you will select the operator for comparison (i.e. less than, greater than, is or is not) and enter the value to which the field should be compared.

Add a Date field to your form.
In any other field you want to show conditionally, navigate to the Advanced tab and enable Conditional Logic.
Set Conditional Logic settings based on your newly created Date field.

With Conditional Logic activated on the field, user input on the Date field determines whether your other field should display. Let’s dig into the specifics of the different configurations for Conditional Logic Dates.

Feature Details

Date-Based Logic

Date-based logic supports static dates, relative dates, days the week, and wildcards. This is done using four comparison operators: is, is not, greater than, and less than. Multiple rules can be combined to match date ranges or exclude specific dates from the match.

Static Dates

To compare a Date field to a static date, select the Date field, choose a comparison operator, and enter the static date to compare against.

gp-conditional-logic-dates-afterThis field will be displayed if the date selected in the Date field is greater than June 30, 2015
Date values must be entered using the US date format: MM/DD/YYYY.

Relative Dates

There’s two ways that relative dates are supported in Conditional Logic Dates:

  1. Comparing a user-inputted date to a relative date.
  2. Comparing the current date to a static or relative date.
User Input

Comparing user input to relative dates is done using the conditional-logic-only merge tag {today}. It allows conditional logic to be applied to fields based on whether the selected date is, is not, is greater than or is less than the current date.

gp-conditional-logic-dates-todayThis field will be displayed if the selected date is today's date.

The {today} merge tag supports modifiers for making date comparisons like:

  • Date is at least 2 weeks away: {today:+2 weeks}
  • Date is no more than 90 days before today: {today:-90 days}
Current Date

To compare the current date to a static or relative date, follow these steps:

  1. Add a Date field to your form (it will default to the Datepicker date type).
  2. Name it something like “Today”.
  3. Open the field settings for this field and navigate to the Advanced tab.
  4. Set {date_mdy} as the default value (this will automatically populate the current date into this field).
  5. Now you can enable conditional logic on any other field and configure date-based conditions by comparing this field to a date value (see examples above).
{date_mdy} merge tag
If you want to hide the “Today” date field from being visible to the user, you can hide it by adding gf_invisible to the field’s CSS Class Name setting on the Appearance tab.

Days of the Week

Use the following conditional-logic-only merge tags to check for a specific day of the week: {monday}, {tuesday}, {wednesday}, {thursday}, {friday}, {saturday}, {sunday}. These are used in the same manner as the {today} merge tag.

gp-conditional-logic-dates-is-monday
Weekend or Weekday

Using the days of the week merge tags, you can apply conditional logic based on whether the date falls on a weekend or weekday.

First, we’ll tackle checking for weekend dates.

  1. Open the field settings for the field that should be shown/hidden based on the day of the week and navigate to the Advanced tab.
  2. Enable Conditional Logic.
  3. Select Any from the drop down that contains the options Any and All.
  4. Select your Date field from the first drop down.
  5. Select is from the second drop down.
  6. Enter {saturday} in the third input.
  7. Add a new rule by clicking the (+) button at the end of the row and follow steps 4 and 5 again.
  8. Enter {sunday} for the third input on the new condition.
gp-conditional-logic-dates-is-weekend

You can follow the same steps to check for a weekday. The only differences are:

  • Select All from the drop down that contains the options Any and All.
  • Select is not from the second drop down of each condition.
gp-conditional-logic-dates-is-weekday

Date Wildcards

If you want to target a specific day of the month, a specific month, or a specific year, you can use the * character as a wildcard.

This field will be displayed if the selected date is within the month of June.
This field will be displayed if the selected date falls on the 5th day of every month.
This field will be displayed if the selected date is within the year of 2018.

Time-Based Logic

Time-based conditional logic supports both static and current time comparisons using the same operators as Date-based logic.

Static Times

To compare a Time field to a static time, select the Date field, choose a comparison operator, and enter the static time to compare against.

gp-conditional-logic-dates-afterThis field will be displayed if the time selected in the Time field is greater than 12:00 pm
Time values must be entered using the US time format: hh:mm am or hh:mm pm
Current Time

Use the special Δ Current Time option to show or hide fields based on the current time.

time-based-conditional-logic-morning-optionsThis field will be displayed if the current time is before 12:00 pm

Check out our How to Setup Time-based Conditional Logic for Gravity Forms the Easy Way tutorial for a detailed walkthrough.

Hooks

  • gpcld_require_date_selection
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 Articles

  • How to Setup Time-based Conditional Logic for Gravity Forms the Easy Way
  • How to Setup Early Bird Pricing with Gravity Forms
  • Conditionally Display a Field Based on a Recurring Date

Perk Deets

  • Version 1.0.15
  • Updated February 27, 2020
  • Released May 13, 2013
  • View Changelog

Changelog

1.0.15

  • Fixed issue where month wildcards were not working as expected.

1.0.14

  • Fixed issue where merge tags such as {today} wouldn't work with conditional logic in Gravity Flow steps.
  • Fixed issue where 12pm was treated as midnight of the next day.

1.0.13

  • Fixed JS error generated by time-based conditional logic when Time field was empty.

1.0.12

  • Fixed issue where Read-Only-enabled Datepicker fields were not correctly evaluated when the datepicker was disabled.

1.0.11

  • Fixed issue where specifying non-lowercased am/pm times in time-based conditional logic rules failed to evaluate correctly.

1.0.10

  • Fixed regression where valid timestamps were not correctly identified causing issues with date-based conditional logic evaluation.

1.0.9

  • Fixed issue where conditional logic is evaluated for form object that has not had its date values converted.

1.0.8

  • Fixed notice generated when invalid form is passed via GF filters.
  • Updated plugin author.

1.0.7

  • Fixed issue where dates were not replaced with timestamps on payment callbacks.

1.0.6

  • Updated frontend JS to handle the date selection requirement for conditional logic evaluation to match how it is handled by PHP.
  • Added JS and PHP hook "gpcld_require_date_selection" to disable date selection requirement for conditional logic evaluation.

1.0.5

  • Fixed issue when validating dates in January.

1.0.4

  • Fixed issue with GP Limit Dates where inline datepickers used in conditional logic did not evaluate correctly.

1.0.3

  • Fixed issue where fields with date-based conditional logic appearing in the order summary were not correctly evaluated in the admin. Added support for style/script minification.
  • Fixed whitespace

1.0.2

  • Added support for Date Field and Date Dropdown as the Date Input Type

1.0.1

  • Added support for converting time-based conditional logic to use UTC timezone.

1.0

  • Updated version to 1.0; all features are considered very stable.
  • Updated minimum GF version to 2.0.

1.0.beta6.4

  • Fixed issue where time-based conditionals were not evaulated correctly when based on entry (rather than posted values).

1.0.beta6.3

  • Fixed issue where wildcard date comparision generated a JS error; they were still using the old method for fetching the date format.

1.0.beta6.2

  • Removed input mask from the rule value input for date-based conditional logic rules; allows merge tags to be used (i.e. {today})

1.0.beta6.1

  • Added support for processing conditional logic on GF feeds.

1.0.beta6.0

  • Added support for Time fields.
  • Added support for Datepicker when specifying date-based conditional logic rules.
  • Added support for Time & Datepicker UI helpers when creating date-and-time-based conditional logic rules in other places than the form editor.
  • Updated conditional logic events to use 'gfield_trigger_change' class rather than manually adding logic events to input markup.
  • Updated inline form script; it has been moved to the gp-conditional-logic-dates.js file.

1.0.beta5.18

  • Fixed issue where admin scripts were output before prematurely

1.0.beta5.17

  • Fixed issue caused by WC GF Product Add-ons plugin; prematurely caches values before appropriate functionality can be applied.

1.0.beta5.16

  • Fixed issue when selected date was 01/01/1970.

1.0.beta5.15

  • Fixed issue when comparing a date to the {sunday} special merge tag.

1.0.beta5.14

  • Added support for wildcard rule values: 9/20/* would match Sept 20th of any year.

1.0.beta5.13

  • Fixed issue where date-based conditional logic on Page fields was not processed correctly

1.0.beta5.12

  • Fixed issue where empty dates compared with {sunday} evalulated as true
  • Fixed issue where admin scripts were not enqueued on all applicable pages

1.0.beta5.11

  • Fixed issue where "Current Time" failed validation if time value was after current time

1.0.beta5.10

  • Fixed issue where "Current Time" compared to 12:XXpm would fail

1.0.beta5.9

  • Fixed issue where form w/ only "Current Time" conditional logic did not register as GPCLD-enabled

1.0.beta5.8

  • Added support for "Current Time" as a special field in the conditional logic field drop down
  • Updated perk to use GP_Bootstrap

1.0.beta5.7

  • Fixed issue where modify_frontend_form_object() was expecting two parameters though it only required one

1.0.beta5.6

  • Fixed issue where Post Custom Field with Date input type were not supported

1.0.beta5.5

  • Update {today} merge tag to use configured WP time as the base timestamp

1.0.beta5.4

  • Fixed issue where $form object was not correclty return for forms that did not contain date-based conditional logic
  • Fixed issue where inline scripts output in footer were still output too early

1.0.beta5.3

  • Updated inline script to output in footer (fixes issues when GF scripts loaded in footer)

1.0.beta5.2

  • Added support for {monday} - {sunday} merge tags for determining the day of the week

1.0.beta5.1

  • Fixed issue where adding Date field to form when WP_DEBUG was enabled would cause JS error.

1.0.beta5.0

  • Added support for {month} and {day} merge tags; can be used to check logic by month month (e.g. '7/{day}/{month}') or by day (e.g. '{month}/15/{year}')

1.0.beta4.1

  • Fixed issue where gf_apply_rules() was being called for Date fields when conditional logic was not applied
  • Fixed conflict with OptimizePress theme which outputs inline scripts earlier than expected
  • Updated {year} merge tag to support a modifier (i.e. "+1 year", "+2 years")

1.0.beta4.0

  • Added support for special {year} merge tag; available only for date-based conditional logic

1.0.beta3.11

  • Fixed issue where date fields in different formats (dot/dash) were not interpreted correctly

1.0.beta3.10

  • Rolled back changes where timestamp conversion happened when the form was retrieved from database; will be updated soon to convert only when processing date logic.

1.0.beta3.9

  • Updated conditional logic so that a date must be selected before logic is processed

1.0.beta3.8

  • Updated how form object was filtered for conversion of dates to timestamps in conditional logic rules; happens globally now excluding the form editor

1.0.beta3.7

  • Added support for Date fields in routing conditions (requires Gravity Forms v1.9.5.7)
  • Added documentation link to first draft post

1.0.beta3.6

  • Fixed issue where inline form script was output incorrectly on AJAX forms
  • Fixed issue where conditional logic was not working when resending notifications (for real this time with more to come)

1.0.beta3.5

  • Fixed issue where conditional logic was not working when resending notifications

1.0.beta3.4

  • Fixed issue where conditional logic was not working when processed in the backend

1.0.beta3.3

  • Fixed issue on Entry Detail view where gform object was not avaialble

1.0.beta3.2

  • Fixed issue where in some cases date format was not specified

1.0.beta3.1

  • Added support for allowing conditional logic date fields to use all GF date formats

1.0.beta3.0

  • Updated add-on to work with Gravity Forms 1.9

1.0.beta2

  • Removed are_dates_converted() method in favor of validating whether the value has been converted to a timestamp yet

1.0.beta1.2

  • Fixed issue where conditional logic date value conversion was not happening when navigating backwards through a form

1.0.beta1.1

  • Fixed issue where conditional logic date value conversion was failing on multi-page forms

1.0.beta1

  • Updated which GF hooks are used to auto-convert date-based conditional logic rules in the $form object

0.4

  • Added support for converting date-based conditional logic rule values on pre-submission and pre-validation; makes it easier for plugins to integrate

All Perks

  • GF Auto Login
  • GF Better User Activation
  • GF Blacklist
  • GF Conditional Logic Dates
  • GF Conditional Pricing
  • GF Copy Cat
  • GF Date Time Calculator
  • GF Disable Entry Creation
  • GF Easy Passthrough
  • GF eCommerce Fields
  • GF Email Users
  • GF Expand Textareas
  • GF File Upload Pro
  • GF Limit Checkboxes
  • GF Limit Choices
  • GF Limit Dates
  • GF Limit Submissions
  • GF Live Preview
  • GF Media Library
  • GF Multi-Page Navigation
  • GF Nested Forms
  • GF Pay Per Word
  • GF PayPal One-time Fee
  • GF Placeholder
  • GF Populate Anything
  • GF Post Content Merge Tags
  • GF Preview Submission
  • GF Price Range
  • GF Read Only
  • GF Reload Form
  • GF Terms Of Service
  • GF Unique ID
  • GF Word Count

Copyright © 2021 · Powered by WordPress · Gravity Wiz LLC

  • Support
  • Affiliates
  • About
  • Sitemap
  • Gravity Perks
    ▼
    • Gravity Perks
    • Tutorials & Snippets
    • About
  • Support
    ▼
    • Documentation
    • Support
    • Account