# Change datepicker date format after form submission \[RESOLVED\]

**URL:** https://community.gravityforms.com/t/change-datepicker-date-format-after-form-submission-resolved/3953
**Category:** Get Help
**Tags:** datepicker, gform\_save\_field\_value
**Created:** [February 18, 2020, 4:34pm UTC](https://community.gravityforms.com/t/change-datepicker-date-format-after-form-submission-resolved/3953 "2020-02-18T16:34:09Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![web2europe](https://avatars.discourse-cdn.com/v4/letter/w/278dde/32.png) [@web2europe](https://community.gravityforms.com/u/web2europe)
#### Post date: [February 18, 2020, 4:34pm UTC](https://community.gravityforms.com/t/change-datepicker-date-format-after-form-submission-resolved/3953/1 "2020-02-18T16:34:09Z")

</div>

Please can someone help me code a function to change the date format of a datepicker field after form submission. I would like to change the format from the default ‘dd/mm/yy’ to ‘d MM, yy’ so when admin views the form entries they will see ‘17 February, 2020’ instead of ‘17/02/2020’.

I tried adding a js script into the form itself, but the form doesn’t validate because it’s expecting the format ‘dd/mm/yy’. I would like the format to be changed after validation (eg, using gform\_pre\_submission).

Thanks  
Paul

---

<div class="post-metadata">

### Author: ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)
#### Post date: [February 19, 2020, 12:01am UTC](https://community.gravityforms.com/t/change-datepicker-date-format-after-form-submission-resolved/3953/2 "2020-02-19T00:01:11Z")

</div>

You can use the [https://docs.gravityforms.com/gform\_save\_field\_value/](https://docs.gravityforms.com/gform_save_field_value/) filter to modify a value before it is saved in the entry. You would need to create the date functions to transform the date format according to your needs. The code would look something like this:

```auto
// submitted date always looks like this: 2020-02-14 
// no matter what datepicker format is used for the field
add_filter( "gform_save_field_value", "transform_date", 10, 4 );
function transform_date( $value, $entry, $field, $form ){
  // set the form ID and field ID here
  if ( $form['id'] === 495 && $field['id'] === 1 ) {
    GFCommon::log_debug( __METHOD__. "(): Value is {$value}." );
    $timestamp = strtotime ( $value );
    GFCommon::log_debug( __METHOD__. "(): Timestamp is {$timestamp}." );
    $value = date ( 'F d. Y', $timestamp );
    GFCommon::log_debug( __METHOD__. "(): Modified Value is {$value}." );
  }
  // return the value, modified or not
  return $value;
}

```

This is PHP code which can go into your theme functions.php file or a custom functionality plugin if you are using one. Change the form ID from 495 and field ID from 1 to match your form and give that a test. This worked for me. Let me know if you have any questions.

---

<div class="post-metadata">

### Author: ![web2europe](https://avatars.discourse-cdn.com/v4/letter/w/278dde/32.png) [@web2europe](https://community.gravityforms.com/u/web2europe)
#### Post date: [February 26, 2020, 3:04pm UTC](https://community.gravityforms.com/t/change-datepicker-date-format-after-form-submission-resolved/3953/3 "2020-02-26T15:04:43Z")

</div>

Thank you, Chris, I’ll see if I can implement this.

---

<div class="post-metadata">

### Author: ![web2europe](https://avatars.discourse-cdn.com/v4/letter/w/278dde/32.png) [@web2europe](https://community.gravityforms.com/u/web2europe)
#### Post date: [February 26, 2020, 3:28pm UTC](https://community.gravityforms.com/t/change-datepicker-date-format-after-form-submission-resolved/3953/4 "2020-02-26T15:28:06Z")

</div>

Hey Chris

Your code worked perfectly, many thanks!

---

<div class="post-metadata">

### Author: ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)
#### Post date: [February 26, 2020, 4:45pm UTC](https://community.gravityforms.com/t/change-datepicker-date-format-after-form-submission-resolved/3953/5 "2020-02-26T16:45:33Z")

</div>

You’re welcome!

---

<div class="post-metadata">

### Author: ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)
#### Post date: [February 26, 2020, 4:45pm UTC](https://community.gravityforms.com/t/change-datepicker-date-format-after-form-submission-resolved/3953/6 "2020-02-26T16:45:37Z")

</div>


