Calculate a due date via merge fields and current date?

Hi there!

I’m hoping that this is possible via Gravity Forms, as I am able to achieve this in Jotforms.

We are using GF to receive order requests from clients. When they get to the last part of the form, I’d like there to be a text section that will calculate the estimated completion date of their order. This would be based on the current days date (the date of the form being submitted), plus +3 days and then +7 days (as our turn around times are between 3 and 7 days).

Any help is much appreciated!

So you need to show a date that is ten days after the date the form was submitted, on the confirmation page after the form is submitted, or before the form is finally submitted (sort of a pre-submission confirmation before they submit)?

Hi! Just to clarify, I need to show a date WINDOW because our turn around times are between 3 and 7 days. So the solution needs to calculate two Dates - 3 days from the current date, and 7 days from the current date. For example, based on today’s date the text I’m envisioning would read something like this:

“Your order is estimated to be complete between the 21st of June and the 25th of June”

Ideally this would be shown on the last page of the form, so a pre-submission confirmation, but if this is not possible the confirmation page is fine too.

OK, got it. I put together a quick form that shows how this can work. You can download the form here:

http://gravityforms.chrishajer.com/wp-content/uploads/gravity_forms/files/gravityforms-export-2020-06-18.json

Save that to your desktop, then go to Forms > Import/Export > Import Forms on your site. Before you can use the form, you need this code to populate three fields in the form with the dates:

add_filter( 'gform_field_value', 'all_the_dates', 10, 3 );
function all_the_dates( $value, $field, $name ) {
	// "21st of June" is the format we want
	$local_timestamp = GFCommon::get_local_timestamp( time() );
	$three_timestamp = ( 86400 * 3 ) + $local_timestamp;
	$seven_timestamp = ( 86400 * 7 ) + $local_timestamp;
	$today = date_i18n( 'jS \of F', $local_timestamp, true );
	$three = date_i18n( 'jS \of F', $three_timestamp, true );
	$seven = date_i18n( 'jS \of F', $seven_timestamp, true );
	$values = array(
		'todays_date' => $today,
		'three_days'  => $three,
		'seven_days'  => $seven,
	);
	return isset( $values[ $name ] ) ? $values[ $name ] : $value;
}

That is PHP code to go into your theme functions.php file, or a custom functionality plugin if you are using one.

Now, with that code on your site, preview the form you imported. You will see the three date fields pre-populated by the code (screenshot). If you submit, you will see on the confirmation screen the estimated delivery dates (screenshot).

The three date field strings are visible now, but you can make those fields hidden visibility if you like, and the procedure will still work.

Let me know if you have any questions.

© 2008 - 2019. Gravity Forms is a project by Rocketgenius Inc.