Use a date field in Gravity Forms to set the value of a Types date field

Gravity Forms can be used to generate new posts. You can add custom fields to the form and capture custom field data for that new post. However, the date field format used by Gravity Forms is incompatible with the date field format required by Types. To fix this, you must use some custom code to convert the Gravity Forms date into a format Types can understand before saving it in the Types date field. Add this code snippet to your child theme’s functions.php file, or create a new snippet in Toolset > Settings > Custom Code.

/* --------------------------------------------------------------------------------------- */
// CONVERT GRAVITY FORMS DATE FIELD TO TYPES FIELD FORMAT
// This function hooks in before data from a GF form is saved to create a new post
// GF date format is not Unix timestamp, so this code converts a date to the proper format
// ----------------------------------------------------------------------------------------*/
add_filter("gform_post_data", "convert_gf_date_to_types_date", 10, 3);
function convert_gf_date_to_types_date( $post_data, $form, $entry ) {
  $gf_form_id       = 123; // the gravity form numeric id
  $gf_field_id      = 456; // the date field numeric id
  $types_field_slug = 'types-field-slug'; // the types field slug (without the wpcf- prefix)

  // you should not edit below this line

  //check if this is the right form
  if ( isset($form['id']) && $form['id'] == $gf_form_id ) {
  // add unix timestamp for date field in meta_input
  $post_data['meta_input']['wpcf-' . $types_field_slug] = strtotime(rgar($entry, $gf_field_id));
  }
  return $post_data;
}

Change 123 to match the Gravity Form numeric ID. Change 456 to match the Gravity Forms date field numeric ID. You can find that by hovering over the field in the Gravity Forms form editor. Change types-field-slug to match the slug of the Types custom date field. Do not use the ‘wpcf-‘ prefix here.