Custom date format [RESOLVED]

I created a class registration form on a custom Wordpress site. Everything works great except the date format. Instead of mm/dd/yy when the email notification is sent to admin and student, it shows yy/mm/dd. I have tried everything to change it but cannot.

The class they are registering for has a date and time, and in the form I have the date in a hidden field with the code being {custom_field:_EventStartDate}. It prints out fine on the email notification but, like I said, the format is yy/mm/dd.

Is there any way to change this format?

I would begin by trying to figure out where the format is being changed. First, be sure it is collected in the correct format in your form.

Then, I would use some logging to see what Gravity Forms is collecting. Make sure logging for Gravity Forms Core is enabled: https://docs.gravityforms.com/logging-and-debugging/

Then, add a custom logging line to your theme functions.php to log the entry (to see what Gravity Forms stored):

GFCommon::log_debug( __METHOD__ . '(): This is my entry => ' . print_r( $entry, true ) );

Next, take a look at the value that is stored in your custom field. Look directly in the database using something like phpMyAdmin.

Finally, post a picture or the text of how you have configured your notification and show us where the date is being added, if not part of the {all_fields} helper output.

Post pictures here of anything you find and need help with.

I have no idea exactly where or how to add this line of code. Do I add it as a single line of code? Do I wrap it in a script? Where do I see the results?

That is a single line of PHP. It is complete as is. You can add that anywhere in your functions.php file so long as it’s not nested in other code or a comment, and is in a PHP block.

It won’t do anything after you add it, unless you enable logging for Gravity Forms Core first:

This is all just troubleshooting to try and find out the format in which the date is being stored in various places.

It doesn’t matter where I put the code, it breaks the functions.php page.

I tried adding it within a current <?php ?> bracket - no luck
I tried adding like this <?php GFCommon::log_debug( **METHOD** . '(): This is my entry => ’ . print_r( $entry, true ) ); ?> no luck

I think this is useless. There should be an option to change the email notifications date format in the email notification and, it should be so easy that a child could do it.

I am using Gravity Forms and The Event Calendar. This should be an easy operation with options to change things without having to add a lot of custom scripts to change the most simplest thing.

If you want help with this, you can send the complete functions.php file to chris@rocketgenius.com and I will place that line of code for you.

This isn’t useless, and right now, there is no option to change the format. My recommendations are designed to help you see where the date format is being changed, so we can give you a method to put it in the format you need. When integrating with other software, there are sometimes additional steps you need to take to get everything working together smoothly.

Your help with my issues is 100% appreciated! I am frustrated on my end that I couldn’t figure this out. I have been designing custom websites for 15 yrs but, I am new to using Wordpress. I built a custom theme structure in WP so I could still build custom sites, no themes. Everything works great, no limitations on designs. Still figuring out some of these plugins and their functions, adding script in the functions.php file.

I did finally figure out what I was doing wrong. I did not add the correct code in the functions.php file. I corrected it last night and it now works. The correct script to make it print out the correct format was:

// Event Start Date - Gravity Forms - The Event Calendar
add_filter( 'gform_field_value_EventStartDate', 'populate_event_start_date' );
function populate_event_start_date( $value ) {
	$custom_field = '_EventStartDate';
	$date_format = 'm/d/Y';
	$value = get_post_meta( get_the_ID(), $custom_field, true );
   	return date( $date_format, strtotime( $value ) );
}

Now everything works. Thanks again for trying to help. I do appreciate it!

You’re welcome. I’m happy you stuck with it and were able to figure that out.