Use Gravity Forms Conditional Logic with Dates

A simple method for showing and hiding Gravity Form fields based on the current date.

Stop! There's a better way.

This snippet is available as a plugin with Gravity Perks, a suite of over 47 premium Gravity Forms plugins!

View Plugin Buy Gravity Perks

You’re probably familiar with Gravity Forms conditional logic. That awesome feature that allows you to show or hide fields depending a set of custom conditions. One feature that isn’t yet support is date-based conditions. Or is it?

This method will allow you to show or hide any field based on a date. You can configure it to show/hide if that date has passed, has not passed or if you are currently on that date.

This tutorial is based on the following example. You are selling tickets to a conference. Tickets sold a week before the conference are $10. Tickets sold within a week of the conference are $15. Let’s dig in!

  1. The Code
  2. Setting Up Timestamp Field
  3. Setting Up Conditional Field

1. The Code

Copy and paste the above snippet into your theme’s functions.php file. This code enables you to populate a field on your form with the current date and time in the form of a UNIX timestamp.

It isn’t super important that you know what a UNIX timestamp is (the number of seconds since January 1, 1970) but it is important to understand that a timestamp is an integer. No weird date formatting just a really big number. For example, this post was published on March 1, 2013. The time stamp for this date is 1362117600.

Gravity Forms conditional logic can’t work with formatted dates but by converting the date into a number we can let Gravity Forms handle the rest.

2. Setting Up Time Stamp Field

Our timestamp snippet doesn’t do much on it’s own. We need to tell it which field to populate with the timestamp. Go ahead and open any form to which you would like to add this functionality and follow these steps:

  1. Add a new Hidden field and label it “Timestamp”
  2. Click on the “Advanced” tab to view the field’s advanced settings.
  3. Check the checkbox labeled “Allow Field to be Populated Dynamically”.
  4. Enabling the “Allow Field to be Populated Dynamically” option will reveal the “Parameter Name” input. Add this value timestamp.

Awesome! Now this field is configured to be dynamically populated with the current timestamp any time the form is viewed.

timestampTimestamp Field

3. Setting Up Conditional Field

Now it’s time for the fun part!

  1. Create another field that you would like to which you would like to apply the date-based conditional logic.
  2. Click on the “Advanced” tab to access the field’s advanced settings.
  3. Check the “Enable Conditional Logic” checkbox.
  4. Select the “Timestamp” field from the first drop down.
  5. Select “less than” or “greater than” from the operator drop down depending on your intent (more details below).
  6. Enter the timestamp for the date this condition is based on (more details below).

For our working example, we will have two product fields. One with the early bird pricing (any time a week before the event) and another for regular pricing (any time within a week of the event).

The event is on March 18, 2013. We want the pricing to be dependent on a date one week before the event, so March 8, 2013 is our “conditional date”. The timestamp for this date (set to midnight) is 1362700800. Based on that conditional date, here is how each field’s conditional logic would be configured:

early-bird-settingsEarly Bird Product Field
regular-settingsRegular Pricing Field

Should I use “less than”, “greater than”, or “is”?

If the field should show/hide if the current date is before the conditional date, you will want to use the “less than” operator.

If the field should show/hide if the current date is after the conditional date, you will want to use the “greater than” operator. You’ll note in the example, the regular pricing has an extra “is” clause. Without this, there would be one second at midnight on the conditional date that neither pricing field would display.

If the field should show/hide between two dates, you will need to create two conditions and use the “greater than” for the starting date condition and “less than” for the ending date condition.

How do I get a timestamp for my conditional date?

The conditional date will also need to be in the UNIX timestamp format. Use this online UNIX timestamp converter to convert the date you want to base your show/hide condition on to a timestamp. Once you have your timestamp, enter it into the last input on the condition row.

Comments

    1. Samuel Bassah
      Samuel Bassah Staff March 22, 2021 at 7:28 am

      Hi Joel,

      Current_datetime() returns the current Date and Time as an Object but Gravity Forms conditional logic requires the Date and Time to be in a UNIX timestamp format, which is why time() is being used.

      Best,

  1. aaiwebadmin
    aaiwebadmin September 9, 2020 at 4:01 pm

    Is there a way to have Gravity Forms reload the timestamp when someone clicks the Next button? I’d like to be able to compare when they landed on the form to when they move on to the next page of the form (they are supposed to be watching a video first). Right now it appears to pick up the timestamp once when the form is first rendered and then use that value indefinitely.

    Reply
    1. Ryan Donovan
      Ryan Donovan September 9, 2020 at 4:16 pm

      Hello, We currently do not have a solution for this, but if you are a Gravity Perks license holder, we may be able to come up with a solution for you. You can contact us through our support channel found here. Have a wonderful day. 😀

  2. Scot MacDonald
    Scot MacDonald June 7, 2020 at 9:19 pm

    David

    Can this be used to set conditional logic on a notification (send if timestamp is after a certain date)?

    Reply
  3. Christopher James
    Christopher James January 14, 2020 at 5:37 am

    This is great! Curious about the logic though. If the function is called “gwiz_populate_timestamp”, why does using “timestamp” work as the parameter name in the hidden field. Surely this should also be “gwiz_populate_timestamp”?

    Reply
    1. David Smith
      David Smith Staff January 14, 2020 at 9:13 am

      Hi Christopher, gwiz_populate_timestamp is the function name. We map the timestamp parameter to this function via the add_filter call. 🙂

  4. hosein
    hosein June 29, 2018 at 3:37 am

    Hi How can I disable certain dates in date picker in gravity forms? I used this code in a html tag in my form but it didn’t work out Please help me this is the code:

    gform.addFilter( ‘gform_datepicker_options_pre_init’, function( optionsObj, formId, fieldId ) { if ( formId == 12 && fieldId == 14 ) { var disabledDays = [’06/15/2014′, ’07/01/2014′, ’07/15/2014′]; optionsObj.beforeShowDay = function(date) { var checkdate = jQuery.datepicker.formatDate(‘mm/dd/yy’, date); return [disabledDays.indexOf(checkdate) == -1]; }; } return optionsObj; });

    Reply
  5. hosein
    hosein June 22, 2018 at 5:07 am

    Hello I want to make date conditional fields based on odd and even days, for example when the date is odd show sth, but when the date is even show sth else How can I do that? Thanks in advance

    Reply
    1. David Smith
      David Smith Staff June 22, 2018 at 11:50 am

      Hm, not sure if this is possible… would this be based on the current date or a user selected date?

    2. hosein
      hosein June 27, 2018 at 3:11 am

      Hi you know, I mean for the ticket reserving when the customer choose odd days(for example the first and the third and fifth day of the month and so on) show specified departure time and if customer choose even days(the second and the forth day of the month and so on)the form show another time options. I mean every other days

    3. David Smith
      David Smith Staff June 27, 2018 at 9:46 am

      I gave this some thought and I can’t think of any ready-made solutions for this one.

  6. Albert de Jager
    Albert de Jager August 29, 2017 at 12:24 pm

    Hi David,

    I have ordered the plugin Perks so I can make a calculation with the time stamp. The only thing i have to know is what calculation i have to use!

    A have a taxi service to the airport and if my clients make a booking for service in 24 hour I want them to pay 10 euro extra.

    So today it is august 28th 18.22 and if they order the taxi for 30th august 18.23 thay pay the normal price and if they order the taxi for 30th 18.22 and earlier they have to pay 10 euro extra.

    I already have a hidden timestamp and thats working, the only thing i need to know is the calculation.

    The website is https://www.luchthavenexpress.nl

    Reply
  7. Albert
    Albert August 27, 2017 at 10:42 pm

    Hi David,

    What i need is I need to charge 10€ when the booking is within 24 hours. Can you tell me if there is a solution?

    Like: today it is august 28 time is 04:40. If my clients book at august 29 04.39 or earlier they pay 10€ more and if they book august 29 04.40 or later then there is no extra charge.

    Can you please help me?

    Thanks, Albert

    Reply
    1. David Smith
      David Smith Staff August 28, 2017 at 8:26 am

      Hi Albert, you say within 24 hours. Is it within 24 hours of the event/product that they are booking?

  8. nigel
    nigel July 19, 2017 at 2:55 am

    is there a solution for dropdown options to base on current time?

    example.

    current time = 1.15pm available choices 12.00 PM 12.30 PM 1.00 PM 1.30 PM 2.00 PM 2.15 PM 2.30 PM

    dropdown will only show choices for

    1.30 PM 2.00 PM 2.15 PM 2.30 PM

    Reply
    1. Nigel
      Nigel July 20, 2017 at 3:42 am

      Hi David,

      the snippet worked after configuration.. however. it does not take into consideration the current date and affected every date. is there a chance you put current date into consideration?

      there can be a field for datepicker, as long as it selects today’s date, the snippet will turn on?>

  9. sneha
    sneha June 26, 2017 at 9:02 am

    Hello David,

    I would like to change the next day date after 12PM everyday If User clicked on a meal under DIET PLANS, user is asked to choose Start Date. Start date must be current date + 4 days at the earliest (provided order and payment is being made before 12 noon. If order and payment is after 12 noon, start date must be current date + 5). So if user is making the order on May 29 (Monday) before 12 noon, earliest start date is June 02 (Friday). User cannot click on June 01 (Thursday) as that is current date + 3 days only.

    This is the site link

    http://healthyfood.studioscue1.online/

    Reply
    1. David Smith
      David Smith Staff June 26, 2017 at 10:38 am

      You can configure two different Date fields with GF Limit Dates to limit the dates that can be selected. One field would be based on if the time is before noon. The other would be if the time is after noon. Then use the “Current Time” special conditional logic option provided by GF Conditional Logic Dates to show the correct field based on the current time.

  10. Lev Abramovich
    Lev Abramovich April 21, 2017 at 10:29 am

    Hi David I have a issue and may be you can guide me. I place a code sniper in to functions.php and follow your instractions. I have form that require registration for specific event which has daily rate and weekly rate So I created 2 dropdown product fields one is for early registration the other for registrartion tha has no discount. ( I test it with changing my PC time to acomodate both time positions) Long story to short when form opens up none of the product fields shown. So my question What am I doing wrong.

    Thank you I appreciate your imput LA

    Reply
    1. Lev Abramovich
      Lev Abramovich April 21, 2017 at 12:03 pm

      I fond problem . I did nor realize that Parameter Name: should be all lawcase I had Timestamp( TYPO) and needed to be timestamp as soon as I crrected it start working

      Thank you for your replu

  11. Phil Macaulay
    Phil Macaulay March 31, 2017 at 8:58 am

    Hi I want to be able to send a notification to a user that submitted a form based on the above idea. So when a particular date is reached (ie that a timestamp is greater than – and that a particular field is not complete) that a notification is automatically sent to the user to remind them to supply information for the blank field. I am using Gravity Forms with Gravity View front end form entries. So an ‘automatic’ notification after a specific date. I do not require the form to be viewed just that a notification is automatically sent – is this possible using the above principle. If not is there an alternative? Kind Regards Phil Macaulay

    Reply
    1. David Smith
      David Smith Staff March 31, 2017 at 11:32 am

      Hi Phil, we have a solution available by request available to Gravity Perks license holders. It will allow you to configure the notification to send based on a variety of time-based conditions screenshot. If you’d like to take it for a spin, pick up a copy of Gravity Perks and send us a request via support.

  12. Wp
    Wp February 4, 2017 at 1:41 am

    Thx for this snippet I can successfully get the number of days between 2 dates. I would like to use the number returned to calculate a price based on that number. So for example, – if number is 2, price is $15 – if number is 3, price is $18 – if number is 4, price is $19 Etc…

    The issue i am having is tryng to calculate these prices, as you can see there is no regular pattern, i have 30 different prices based on the number returned!

    Any help appreciated

    Reply
  13. Chris
    Chris December 6, 2016 at 8:44 am

    Can you send notifications based on a date? For example, send out the customer notification 2 weeks prior to a date field. I want to be able to send a one-time payment reminder to new customers 2 weeks prior to their very first bill being due. In the form I would put a “Due Date” field and the system would send out the desired Notification 2 weeks prior to that date.

    Reply
    1. David Smith
      David Smith Staff December 6, 2016 at 9:06 am

      Hi Chris, we actually just did a freelance project and have a plugin in-the-works for this. It’s not ready yet but it’ll be part of the Gravity Perks package when it is.

  14. Dave
    Dave September 5, 2016 at 5:16 pm

    Hi! I’m wondering if it’s possible with GP Conditional Logic Dates to use this with Confirmations? Basically I want to be able to set up confirmations that send users to various pages depending on the date selected but of course dates are not available in conditional logic in the Confirmations section.

    Reply
    1. David Smith
      David Smith Staff September 10, 2016 at 9:06 am

      Hi Dave, I think I answered this question via email as well but I wanted to answer here for the benefit of others with the same question. Yes, GP Conditional Logic Dates is supported with confirmations for exactly this use-case. :)

  15. Alejandra
    Alejandra May 23, 2016 at 10:29 pm

    Thank you very much for this! I hope you can answer my question (obviously not an expert).. I’m trying to add a timestamp conditional to a field so it would show or hide depending if a specific date is selected on a date picker. Is this possible?

    Reply
  16. Scott
    Scott April 22, 2016 at 3:39 pm

    Hi David,

    Apologies if this has been asked before. Looking to create multiple notification options where it can be sent to one email address during normal work hours and a different address outside of those times. M-F 7AM-5PM it goes to aaa@aaa.com and nights & weekends it goes to bbb@bbb.com. GP Conditional Logic Dates seems to only offer the day of the week, but not the time of day.

    Any ideas?

    Reply
    1. David Smith
      David Smith Staff April 22, 2016 at 4:05 pm

      Hi Scott, GP Conditional Logic Dates does not yet support Time fields or working with the current time. If you’d like to commission this feature on an accelerated timeline, get in touch.

  17. dhruv
    dhruv April 21, 2016 at 4:46 pm

    Is it possible to this kind of conditional logic? If a person selects a date and it falls on sunday, I want option 1 to show up, on monday, option2, tuesday option3 etc

    Reply
  18. Fred Dox
    Fred Dox April 21, 2016 at 12:11 am

    Hi, I am very interested in this plugin. Is it possible to make a conditional logic when selecting week days or weekends? I have a service website that offer weekend services and would like to show all fields when someone selects a week day or different fields when they select a weekend.

    Thanks a lot, Fred Dox

    Reply
    1. David Smith
      David Smith Staff April 21, 2016 at 8:08 am

      Yes, sir. Here’s how you’d set that up:

      1. Install Gravity Perks and GP Conditional Logic Dates.
      2. Add a Date field.
      3. Add two Drop Down fields. One for your weekday options and another for your weekend options.
      4. On the weekday options, setup your conditional logic like so (screenshot).
      5. On the weekend options field, setup your conditional logic like so (screenshot).

      That’s it. :)

    2. Fred Dox
      Fred Dox April 24, 2016 at 6:16 pm

      I can’t see your screenshots… just installed the plugin thought I might figure it out myself. Please would you explain me again how can I do a conditional logic for a drop down if someone selects a week day and another one if they select a weekend day. Thanks

    3. Fred Dox
      Fred Dox April 24, 2016 at 6:27 pm

      I just figured it out. Turns out I can type each day (monday, tuesday etc…) thanks for this great plugin. Saved me hours of working around GF css. Thanks a lot.

    4. David Smith
      David Smith Staff April 25, 2016 at 2:40 pm

      Awesome, Fred. Glad you were able to get this sorted. Let me know if you have any other questions. :)

  19. Fabien
    Fabien March 7, 2016 at 2:57 am

    Hi, How can i do to use timestamp to show fields only for users registered before a “timestamp” date ? Thanks for your help

    Reply
  20. Des
    Des March 1, 2016 at 12:01 pm

    Is there a way to do with the Conditional Logic that 10% is calculated after the 15th of every month when the form is submitted?

    Reply
    1. David Smith
      David Smith Staff March 8, 2016 at 12:19 pm

      Hi Des, do you meant it adds a 10% fee if the form is submitted after the 15th of the current month? If so, yes but you will need GP Conditional Logic Dates. With it, you can setup a Product field to only appear with a conditional logic rule like this:

      Show this field if all of the following match:
      [ Date Field ] [ is greater ] [ {month}/15/{year} ]

  21. Nicole Guthrie
    Nicole Guthrie October 8, 2015 at 10:13 am

    Would love to use this snippet on my site. Cannot for the life of me figure out where to paste the snippet. I have looked everywhere. Could you please expand upon step 1? All the rest makes sense to me.

    Thanks!

    Reply
  22. Kamil Acero
    Kamil Acero August 17, 2015 at 7:50 pm

    I am trying to figure out how to calculate the price per week depending on the date. So for example the price per week for the accommodation from January 1 to May 15 is 300 dollars per week. However, between May 16 to Nov 15 is 350 dollars per week. So if someone is registering on May 1 and wants to stay for a total of 6 weeks, he would pay 300 dollars for the first two weeks and then 350 for the last 4 weeks. How can i make the form calculate this?

    Reply
    1. David Smith
      David Smith Staff August 20, 2015 at 8:57 am

      First, I would use GP Conditional Logic Dates to accomplish this. It’ll be a lot easier. Next, you can either create multiple products and then show and hide the correct product (by price) based on the Date selected (via the GP Conditional Logic Dates perk) – or – you can keep one Product field and change the price with the GP Conditional Pricing plugin. The demo for that perk actually shows some date-based pricing logic.

  23. Johan
    Johan July 12, 2015 at 5:21 am

    Hey Dave,

    Again my compliments for a snippet of yours; they work really well!

    I was wondering if you have an idea about the following challenge: I do want to use this snippet, but in stead of a fixed date (so with a UNIX timestamp), I would like to always take the day of today as ‘starting point’ for the counting.

    A bit more explanation: I am a travel agent and would like the flight tickets I sell, to automatically change in prize (in other words: other product fields to be shown) depending on the number of days from today someone wants to book a ticket for. So: higher price if the selected date is today (so today + 0) and a lower price if they want to book a ticket for in a week (so today + 7 days).

    Hope you can help me out with this :) .

    Thanks in advance!

    Best regards,

    Johan

    Reply
    1. David Smith
      David Smith Staff July 14, 2015 at 11:37 pm

      Hi Johan, GP Conditional Logic Dates supports a special merge tag {today}. This merge tag supports a special modifier for extending (or reducing) the date: {today:+7 days}. You could then combine this with GP Conditional Pricing to change the price of your product depending on the selected date. Here’s an example of what the logic might look like (example).

  24. Charles
    Charles May 19, 2015 at 1:43 pm

    Dave,

    So with the updates to the twenty-twelve theme the Timestamp doesn’t want to work for me.

    Pasting <?php /** * Use Gravity Forms Conditional Logic with Dates * https://gravitywiz.com/use-gravity-forms-conditional-logic-with-dates/ */ add_filter(“gform_field_value_timestamp”, “gwiz_populate_timestamp”); function gwiz_populate_timestamp( $value ){ return time(); }

    into the functions.php breaks the file.

    with the following error:

    Parse error: syntax error, unexpected ‘<‘ in /xxxx/xxxx/xxxxxx/xxxxxx/pages/wp-content/themes/twentytwelve/functions.php on line 12

    This script was a huge help but now it seems to leave me hanging…. please help.

    Reply
  25. Catharine
    Catharine April 15, 2015 at 5:45 am

    Hi David, Thanks for creating this great bit of code. Can it also be adapted to work with times? E.g. if I have a time field and I wanted to apply conditional logic in a later field which used the times inputted earlier. Hope this makes sense. Thanks, Catharine

    Reply
    1. David Smith
      David Smith Staff April 16, 2015 at 8:39 am

      Hi Catherine, this is a great idea and is something that I’d like to implement in the future. For now, there isn’t a simple way to add support for it in the same way as the dates here.

  26. Charles
    Charles February 24, 2015 at 11:41 pm

    Dave, I want to start by saying this code is such a blessing. We’ve struggles with so many work aroundss that it was very difficult and had lots of visitors complaining. Thanks.

    With that said, and meant, I am having an issue when it comes to drop down product in Gravity Forms…

    When I have a single product the code works great (again, very thankful) but when I add a product with three options via drop down menu it breaks and doesn’t show that field. Any suggestions?

    I created an example: http://www.bciohio.com/pages/?p=1738

    When you select registering as an individual the which show the issue the drop down to choose the event(s) they are attending will not show up (it has the condition set). When registering as Husband & Wife you’ll see the drop down does display as there is no condition.

    Hope that helps

    Reply
    1. Charles
      Charles February 24, 2015 at 11:43 pm

      Never mind… it work on the conditional page… now I have to think this through.

      Thanks again for a great code.

  27. Pelle
    Pelle January 26, 2015 at 7:06 am

    Hi!

    I’m helping a cab company and they don’t want people to place bookings closer than 24 hours.

    Would it be possible to deactivate the send button if the time set in the time field is within the next 24 hours from booking?

    Regards Pelle

    Reply
  28. gabrielle
    gabrielle December 4, 2014 at 10:53 am

    Hi, how can i create variation for price using text input field? I try many plugins already, and waste few days for work and money…my project drives me crazy ;/ I try to achieve something like that: If width = 20cm to 40cm and height = 60cm to 80cm then price =myValue I need use input fields, i build this with variation in WooComm. but its to heavy for site… is there a way to achieve that with conditional logics? I dont want to buy another useless plugin ;/

    Reply
  29. Chris
    Chris November 20, 2014 at 10:15 am

    I have the Gravity Perks package (and love it!) but I am curious if this Date snippet could be used with Notifications?

    For example, I send out a first payment reminder to my new clients two weeks before their first payment is due. (I do not send any additional reminders, just on this first one.) On my Gravity Form, I have name, email address, upload file, and first payment date fields. Could this Date snippet be used to send a Notification if that First Payment Date field is equal to or less than two weeks from today’s date?

    Reply
  30. Michael
    Michael October 21, 2014 at 12:18 pm

    Hello David. Do you have a Perk (in the works) that will allow to remove a product option or checkbox based on a date? We basically have a list of events open for registration, and to allow for multiple event signup, they are listed as options under a hidden product. The issue is, i now need to go in every week and delete the event (option) that has just passed – is there a way to hide the option based on the date?

    Thanks! Mike

    Reply
    1. David Smith
      David Smith Staff October 21, 2014 at 2:12 pm

      Hi Michael, the closest perk I have is the GP Conditional Logic Dates. Unfortunately, this would not provide the option to show/hide a specific option of an Option field but rather the entire field. You could create multiple copies of the option field, each with one of the options removed depending on the date. Not ideal but one way to accomplish it.

  31. Chris
    Chris September 26, 2014 at 1:03 pm

    Could this be modified to display a gravity form a certain hours of the day?

    For example if you have a restaurant and you want to display the online order form during the hours they have the restaurant open and then when the restaurant is closed hide the form and only display a message that they are closed.

    Currently you can only do this between a set of 2 dates. I am looking to have it setup daily to adjust for certain times for each day of the week.

    Any thoughts/suggestions?

    Reply
  32. David
    David September 19, 2014 at 7:22 am

    Here’s a strange one: I’ve got a client who’d like to only make a form “submittable” between certain hours of every day. (She only wants users to be able to submit the form between 9am and 6pm Parisian time each day).

    Any ideas on how to do this?

    Thanks!

    Reply
    1. David
      David September 19, 2014 at 12:28 pm

      That worked great. Thanks so much for the answer. Beyond putting the code you supplied in functions.php, here are some follow up instructions:

      On the Form Settings page, under restrictions, you can enable and configure the form schedule. Set the start and finish date and time as desired for one day. You will then need to add the following to your theme functions.php file to override the start and finish date:

  33. Houston Brown
    Houston Brown August 18, 2014 at 2:05 am

    Bet, This snippet has saved on many of forms. Thank you. Not sure why GF does not implement this in their plugin.

    Could you tell me, is there a way to do this without including the year? in other words, I want this to happen the same time every year, but it would be nice if I didnt have to come back to the site to make the time adjustments to the form.

    Many thanks, Houston

    Reply
    1. David Smith
      David Smith Staff August 18, 2014 at 5:19 pm

      This is not currently possible but I’d love to add support for it. I’ve sent you an email to see if you’re interested in commissioning the functionality.

  34. Lauren
    Lauren July 21, 2014 at 10:33 am

    I am looking to validate an age using the GF datepicker field. Is there a way this code could be modified to check if the date they inputted as their date of birth would make them older than 21?

    Reply
  35. Bet Hannon
    Bet Hannon June 24, 2014 at 6:26 pm

    We have been using this conditional date solution on a number of registration forms to control early registration discounts. Works great! But now we’ve had a couple of times where one person has received the discount when they shouldn’t have– and when no one else is. Could the timestamp be pulling the date from the user’s computer & that date is wrong?

    What else could be happening in this one-off case?

    Reply
    1. David Smith
      David Smith Staff June 27, 2014 at 6:14 pm

      Hi Bet, glad you’ve found this snippet useful. Was the value in the Timestamp field eligible for the discount while the entry date was not?

    2. Bet Hannon
      Bet Hannon June 30, 2014 at 11:28 pm

      David, I hadn’t thought about comparing those two fields, and when I exported to look, the times when someone got an “early” price when they shouldn’t have, there was NO timestamp in those entries– the timestamp field was blank. What would cause that?

      I looked back, and there were a couple of times that no timestamp appeared before this, but since those people got the early price like they should have, we didn’t realize there was a problem.

      Even if we can’t figure out WHY this is happening, can you make a suggestion about how to best deal with it? I don’t want to delete the early price field and lose that data for the already-registered. Will shifting the regular price field so that it comes above the early price field mean that the regular price will show first? (Since I can’t replicate this, I’m not sure if both pricing fields are showing…)

    3. Bet Hannon
      Bet Hannon June 30, 2014 at 11:34 pm

      This week, the missing timestamps occurred in two registration forms from the same family, registering their kids for camp– on two different days last week. Could it be some setting on the user’s computer that somehow blocks the timestamp? That seems so unlikely, but it is not a coincidence that it occurred twice for the same user on different days.

  36. Ariana
    Ariana June 6, 2014 at 4:35 pm

    Can you specify where in the functions.php file do we insert the aforementioned snippet? I too get a blank page with or without the php tag. Thank you.

    Reply
    1. David Smith
      David Smith Staff June 6, 2014 at 10:19 pm

      Hi Ariana, if you can you copy and paste the contents of your functions.php file into a pastie I can show you how this snippet should be added.

    2. Ariana
      Ariana June 7, 2014 at 8:53 am

      David,

      I figured it out after I noticed the “watch this” link to your video tutorial below this comment box. I have it now. Thank you.

  37. Chemin Chu
    Chemin Chu March 5, 2014 at 5:50 pm

    Hi David:

    I added your code into functions.php in our school website and updated. It turned out the whole website became blank. Fortunately, the host had the backup and recovered it. Where did I do wrong?

    Reply
    1. David Smith
      David Smith Staff March 5, 2014 at 8:27 pm

      Hi Chemin, I’m guessing you added this to your theme’s functions.php file via the WordPress theme editor. This isn’t ideal for the reason you encountered today. If you break something, you can’t readily undo the change. I’d recommend only making changes to your functions.php file via FTP. This way you can immediately undo the change and re-upload the original file.

      With that said, I’m betting that your functions.php file already had an opening <?php tag and you left the <?php tag at the beginning of the snippet in there as well. This will cause a fatal error. Try repasting the snippet but removing the opening <?php tag from the snippet before saving.

    2. Chemin Chu
      Chemin Chu March 17, 2014 at 4:04 pm

      Thanks, David for your solution and I do have timestamp in my Gravity Form successfully. Is it possible to set up a conditional field on hours only without dates? For example, a student arrives school after 10 am of the day, the student will be considered absence of the day.

  38. Marc
    Marc March 4, 2014 at 5:28 am

    Hi GF,

    I can’t copy the code in functions.php. I get an php errorline.

    And besides this errror I need a conditional logic for every sunday of the year. Because I’m using the form for a breakfast service. You can order on middays and saturdays from 7:00 a.m. On sunday from 8:00 a.m. Here’s the logic needed. Is this possible?

    Regards,

    Marc

    Reply
    1. David Smith
      David Smith Staff March 5, 2014 at 8:35 pm

      Hi Mark, could you share the exact error you’re getting? Make sure you remove the opening <?php tag form the snippet if your functions.php already includes an opening <?php tag.

      This method will not support the logic you want to do; however, this is a planned feature for the Conditional Logic Dates perk.

  39. Janel
    Janel September 30, 2013 at 3:33 pm

    I’ve used this also with the conditional logic within GF Notifications, and it works great here too.

    But I’m wondering if there a way to apply this logic from a business hours perspective?

    To clarify: I want to send one notification if the time the form submitted falls between 8am – 5pm Mon-Fri, and another notification if it is submitted after 5pm Mon-Fri, or onSat/Sun?

    To test, tried returning date(‘l ga’); and then setting two conditions: one greater than Monday 8am AND one less than Monday 5pm, but it isn’t working as expected. I’m probably missing something with how the less than / greater than applies to non-specific dates …? Any guidance on this would be amazing.

    Thanks for all your stellar work.

    Reply
    1. Janel
      Janel September 30, 2013 at 4:25 pm

      Not sure if my last comment went through.

      I’ve used this successfully with conditional Notifications, it seems to work great here too.

      I’m wondering if there is a way to apply this from a business-hours perspective. That is, send one notification if the form is submitted between 9am – 5pm Mon-Fri, and another if it is sent after 5pm on weekdays or on weekends.

      Any guidance greatly appreciated, and thanks for all the great work!

    2. Janel
      Janel September 30, 2013 at 5:51 pm

      Just figured it out the answer to my question. … set up a conditional to return true if it’s outside of business hours, or Sat/Sun.

      Then just created 2 notifications, one that gets sent if the timestamp is set to 1, and another if the timestamp is set to 0.

  40. Ray Gulick
    Ray Gulick September 24, 2013 at 1:01 pm

    This is brilliant! But I’m having a problem. I’m trying to provide registration for 2 different events (different dates), which the visitor selects from a dropdown menu. The I set 2 conditional pricing fields, to show the appropriate pricing field based on event selection and timestamp for the earlybird date for the event. The problem is, only the second conditional field works. If I switch the position of the two conditional fields, the second one works and the one that previously worked does not. What’s going on here?

    Reply
  41. Daniel Weinshtein
    Daniel Weinshtein August 28, 2013 at 11:30 pm

    Thank you for this!

    But what about if the days are constantly changing, is there a way where we can have the timestamp changing, and hence the conditional factor changing?

    Thank you!

    Reply
    1. Daniel Weinshtein
      Daniel Weinshtein August 28, 2013 at 11:58 pm

      How do I make it so, that when someone selects a date that is more than 5 years so…(2008 and less)…that a conditional field appears?

      Thank you! :)

      Daniel

  42. Use Gravity Forms Conditional Logic with Dates - Gravity Wiz - jpollock July 31, 2013 at 8:31 pm

    […] Use Gravity Forms Conditional Logic with Dates – Gravity Wiz. […]

    Reply
  43. chris vandeventer
    chris vandeventer May 19, 2013 at 2:03 pm

    I am wanting to do something similar for a youth soccer club where the parent would enter the date of birth for the child and conditional logic would be used to determine what classification the child would be. for instance I want to set the logic that if the date is after 8/1/2000 but before 7/31/2002 it would be a U12 classification. So if the DOB was entered as 11/13/2001 a message would be returned to the entry form that the player is U12… 8/1/2002 – 7/31/2004 would return U14, etc. and so on.. Is this possible?

    Reply
  44. Eduard
    Eduard May 10, 2013 at 4:40 pm

    I have a problem… Regarding the usage of conditional logic and date fields (JQuery Datepicker).

    Scenario: -I have a JQuery Datepicker in my Gravity Form -I have already changed the locale and disabled values in the past -I now want to hide/show fields depending on wether a weekday or a weekend is selected.

    How would I go implementing this?

    Cheers Eduard. Help much appreciated

    Reply
    1. David Smith
      David Smith Staff May 12, 2013 at 11:09 pm

      Hi Eduard, awesome question. This is a little too involved to demonstrate on the fly; however, I am working on a perk for date-based conditional logic which I’d love to add support for this to. Keep an eye on upcoming perks and we’ll see if it makes it into the 1.0 version.

  45. Using Conditional Logic with the Date Field in the Gravity Forms Plugin for WordPress - Inside the Nerdery April 19, 2013 at 9:01 am

    […] found an interesting example of using a hidden field for date handling, but it relies on setting the date when the form loads. I couldn’t find a way to hide and […]

    Reply
    1. David Smith
      David Smith Staff April 16, 2013 at 10:00 pm

      That is not possible with this particular snippet. You could; however, make different checkbox fields available based on the date with each having the appropriate checkboxes available.

  46. Azy
    Azy March 16, 2013 at 9:45 am

    Awesome site David.. loads of rare useful stuff here..

    I have a question (i tried searching the site but couldn’t find a related article).. how can I limit the years in the date field, for example users are given only the option of selecting a date between year 2000 – 2010. Thanks

    Reply
  47. glen
    glen March 7, 2013 at 10:23 am

    David, By chance, do you have a quick rundown on how to show form entries, say, for the last 7 days?

    I’m using the GF Directory, the author replied to me with the php below, I’m not a programmer by trade, and he’s not too good about responding consistently to anyone on the WP site, and I was just wondering if you knew how I can use the php code or if you had another alternative on how to limit what shows, based on submission date?

    This is what he posted…

    I know my way around the server, can do changes and the like, just not always sure with certain things, like this, for example. I was hoping to find an example with your other great snippets you’ve posted on your site, but quickly learned I was out of luck.

    I tried using a PHP shortcode plugin, partially worked and was able to make the directory show via the shortcode plugin, but also discovered it wouldn’t allow me to use customization offered via the directory plugin.

    If you can assist in anyway, I’d be most grateful.

    Thanks in advance.

    ps. after stumbling upon your blog, i never realized how much gf can do and am slowly learning more each day!

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.

Grab a bundle of free Gravity Forms plugins

Enter your email and receive our most popular free plugins and snippets, plus access to hundreds of others.

This field is for validation purposes and should be left unchanged.