Show day of week in notification

I’ve used a date-field in a form. In the conformation mail and notifications, I would like to display the day of week before the date, for example: Monday 19-05-2020. Is there a way to do this?

Hi Willem. You can do this with a small bit of code added to your theme functions.php file. Here’s the code:

add_filter( 'gform_merge_tag_filter', 'add_day_of_week', 10, 6 );
function add_day_of_week( $value, $merge_tag, $modifier, $field, $raw_value, $format ) {
  // if it's the all_fields merge tag, and field ID2, and the modifier is dow i.e. {all_fields:dow}
  if ( $merge_tag == 'all_fields' && $field->id == '2' && $modifier == 'dow' ) {
    // figure out the day from the date
    $timestamp = strtotime( $raw_value );
    $value = date( 'l', $timestamp ) . ' ' . $value;
  }
  // return the unmodified or modified value
  return $value;
}

Change the field->id from 2 to whatever your date field is.

Then, for the all_fields merge tag in your notification, add the modifier :dow like this:

{all_fields:dow}

That will output the day of week, with a space, and then your formatted date. Let me know if you need any assistance with that.

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