PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Calculate a Date

  1. Would anyone know how I might calculate a month based on the date a user input?

    This isn't specific to the new "calculations" functionality or anything, but probably something that involves a little extra work on my part.

    For example, I want to allow the user to choose between three options in a dropdown question that asks, "How soon do you want this?":

    1. 1-13 days
    2. 14 - 21 days
    3. 22 days or more

    And then have a date input (that isn't shown to the user, just for internal purposes) display the applicable month. So depending on what they chose:

    1. We'd leave the month as the current month.
    2. We'd put it as the following month.
    3. We'd put it as 2 months out.

    Any ideas?

    Posted 11 years ago on Friday May 11, 2012 | Permalink
  2. David Peralty

    You will want to have an empty hidden field, you won't do anything with this field until the form is submitted. Then using http://www.gravityhelp.com/documentation/page/Gform_pre_submission you can calculate the difference in dates based on what they selected and populate your hidden field so the value is sent to the database.

    To figure out the difference, you'll have to come up with some PHP code using the date function.
    http://php.net/manual/en/function.date.php

    Posted 11 years ago on Friday May 11, 2012 | Permalink