Display Captured Dates in Any Format with Gravity Forms

Capture a date in one format (like 10/10/2021) and display it another (like October, 10th 2021).

gravity forms conditional date tags

November 21, 2024: Added support for specifying a locale parameter to apply to all forms or specific forms.

September 6, 2023: Updated to support &comma as a replacement for , for commas for better compatibility with Populate Anything's LMTs.

November 5, 2021: Fixed issue where original date format was not accounted for when parsing date for formatting.

  1. Overview
  2. Using the Plugin
    1. Prerequisites
    2. Merge Tag Modifier
  3. Use Cases
    1. Event Reminders
    2. Append Date to Unique IDs
    3. Create Gravity Forms Conditional Merge Tags using Shortcodes
    4. Gotchas
  4. Summary

Overview

Gravity Forms makes it easy to capture dates in form entries. Simply add a Date field to the form, and your user can easily select a date from the built-in datepicker.

Displaying those dates in Confirmations and Notifications is equally easy. Insert the Date field’s merge tag and it will automatically turn into the submitted date when the Confirmation displays or the Notification is sent. Further down, we’ll also cover how to use Gravity Forms’ date merge tags to populate your entries dynamically.

To display the value of an entered date (or any other field type) within the form, check out GF Preview Submission.

The format that outputs when using a date field’s merge tag is determined by the Date Format setting. It defaults to mm/dd/yyyy and offers a handful of variations, such as dd-mm-yyyy many others.

While versatile, I often find that I want more control over the date formatting, especially when using dates in notifications.

This plugin adds the ability to use PHP’s date format to format the output of date merge tags. This adds granular and flexible options for displaying dates to your users.

Using the Plugin

Prerequisites

Confirm that you have Gravity Forms installed and activated and that you’ve installed and activated the plugin.

Merge Tag Modifier

With the plugin installed, first insert the merge tag for a Date field anywhere that it’s supported. To format the date, add a merge tag modifier with the appropriate date formatting characters.

gravity forms merge tags

Refer to the PHP docs for how to format the characters to get the desired outcome. Below are some examples of a couple of different modifiers and their formats.

{Date:1:l F jS Y}Friday October 15th 2021
{Date:1:d-m-y}15-10-21
{Date:1:M d}Oct 15
Week {Date:1:W}Week 41

Use Cases

There’s a number of different ways formatted dates can be used in your forms, and we want to highlight a couple of use cases.

Event Reminders

We tend to remember events better if we can associate them with a day of the week. Oh, the webinar? That’s next Wednesday! When is Lalya’s race? Friday the 13th. 😱

We made a Webinar Signup form for our GF Inventory demo. The user selects the date they’d like to attend from an inline datepicker. On the confirmation, we format the date to include the day of the week so it’ll stick better in their memory.

gravity forms email confirmation

Want to send timed event reminders? Gravity Forms Notification Scheduler allows you to send custom messages before and after date-based fields submitted on a form. If you’re using a form for an event, appointment, or reservation, you can schedule custom notifications (personalized with merge tags, of course) to your users in the days leading up to the event as a reminder, or after.

For example, send personalized reminders for an upcoming reservation with helpful tips on how to prepare or what’s on the menu. Or send a feedback request a few days after the submitted date.

Gravity Forms Notification Scheduler also allows you to send notifications based on chosen dates, after any notification event, recurring forever, or ended after some time. Learn more about Gravity Forms Notification Scheduler!

Append Date to Unique IDs

Using this plugin, you can format the date merge anywhere that it is supported, which includes the prefix or suffix of unique IDs generating with GF Unique ID. For example, say you want to use a sequential ID that is prepended with the current date in yyyymmdd format. First, add a Date field to the form and use the {date_mdy} merge tag in its Default Value to populate the current date into the field when the form is loaded.

gravity forms unique id

Then, add the merge tag for that Date field into the Prefix setting for your Unique ID field. Add the following merge tag modifier to format the date in yyyymmdd format: {Date:1:Ymd}.

gravity forms unique ids

Then an entry is submitted, the date will be prepended to the unique ID.

gravity forms conditional merge tags

Create Gravity Forms Conditional Merge Tags using Shortcodes

You can use Gravity Forms Conditional Merge Tags with Gravity Forms Conditional Shortcode so that different content can be displayed in Confirmations and Notifications based on the values in an entry. You can take this one step further with this plugin by altering the displayed date format depending on the user’s country.

[gravityforms action="conditional" merge_tag="{Country:1}" condition="is" value="United States"]
Interview Date: {Interview Date:2:d-m-Y}
[/gravityforms]

[gravityforms action="conditional" merge_tag="{Country:1}" condition="isnot" value="United States"]
Interview Date: {Interview Date:2:m-d-Y}
[/gravityforms]

Gotchas

Commas are a reserved character in Gravity Forms merge tags. If you need to use a comma in your date format, you can escape it with its HTML entity: ,. For example:

{Webinar Date:2:l, F jS} → Wednesday, September 15th

Summary

This is a simple plugin that gives you the ability to have full control over the formatting of the date merge tag. Let us know how you’re using it. If you have ideas on how we can improve it, please let us know!

Use Populate Anything to capture dates in any format in real time

With Live Merge Tags, this merge tag provides a powerful way to show and capture dates in any format you need live on the form. This is particularly useful in HTML fields.

Populate and format Dates and Times based on user input, in real time

Populate and format dates and times live while the user is filling out the form. This is perfect for calculating delivery or expiration dates or indicating a return date and time for your rentals. Populate Dates also includes full formatting support (much like this plugin) so you can populate dates in the exact format you want.

This Date & Time Calculator can help with complex date and time calculations based on input

Calculate the minutes, hours, days, years between two dates or times. Need to determine how many week or weekend days are between two dates? Or deduce the user’s age based on their birthdate? Date Time Calculator has you covered!

Limit the Dates a user can select using Limit Dates

If you’re using a datepicker, rarely do you want to let the user select just any date. Use Limit Dates to specify your date requirements and the datepicker will be restricted automatically. Limit Dates automatically integrates with GF Inventory to block dates that are fully booked.

Comments

  1. Geoff
    Geoff May 10, 2024 at 5:27 pm

    Experiencing an odd issue… when I submit the form from the site, the date format I set in the merge tag (F j Y) does not get applied in the email notification I receive. But if I use the “Resend” option for an entry, it does get formatted.

    Formatting in email notification received after form submitted: 15/2/2024

    Formatting in email notification received using GF “Resend” option for the entry: February 15 2024

    Reply
    1. Samuel Bassah
      Samuel Bassah Staff May 13, 2024 at 5:11 am

      Hi Geoff,

      This is strange. I just tested the snippet, and it works as expected when the form is initially submitted. What you’re experiencing may be specific to your website. I suggest you run a conflict test to check if another plugin is causing this. If the conflict test doesn’t help, you can submit a ticket via our support form, so we look into this issue further.

      Best,

    1. Scott Ryer
      Scott Ryer Staff September 1, 2023 at 1:40 pm

      Hi Tony,

      Yep! You can use Populate Anything’s live merge tag feature to display the date output in another format in another field. This works both with HTML fields and as the default value for another field.

      Live Merge Tag example

    2. Tony Schwartz
      Tony Schwartz September 1, 2023 at 9:19 pm

      The comma gotcha is not working for me.

      Code: @{:33:F j, Y}

      Output: September 1

      No year is being shown.

    3. Samuel Bassah
      Samuel Bassah Staff September 4, 2023 at 5:45 am

      Hi Tony,

      I’m able to recreate the issue. It looks like the snippet doesn’t support using a comma as you have it. I’ll forward this to our product manager as a feature request to add support for using a comma in the dates.

      Best,

    4. David Smith
      David Smith Staff September 6, 2023 at 9:00 pm

      Hey Tony, I’ve updated the snippet to support using , instead. For some reason, Populate Anything Live Merge Tags choke on the , entity. Get the latest version above and update your date modifier to use &comma. 👍

    5. Tony Schwartz
      Tony Schwartz April 3, 2024 at 3:55 pm

      I have a new issue with this.

      This is my code:

      This proposal expires on {Quote_Expiration_Date:2:F j, Y}.

      And it spits out:

      This proposal expires on April 23&am04Z;2024-04-23T00:00:00+00:0020240404am; 2024.

    6. Samuel Bassah
      Samuel Bassah Staff April 4, 2024 at 3:50 am

      Hi Tony,

      I am unable to recreate this issue, when I tried, the merge tag you’re using. I’ll be contacting you via email to request for more information on this.

      Best,

  2. Trevor S
    Trevor S June 6, 2023 at 4:54 am

    Hello – using WP 6.2.2, we’ve noticed that email notifications from a form aren’t firing if both Format Date Merge Tags and GP Populate Anything are enabled. Disabling either of them solves the problem. No obvious errors in the server log though.

    Reply
    1. Samuel Bassah
      Samuel Bassah Staff June 6, 2023 at 11:34 am

      Hi Trevor,

      This isn’t a known issue and I am unable to recreate it, so I will be contacting you via email to request more information so we can dig into this.

      Best,

  3. Geoff
    Geoff April 5, 2023 at 7:15 pm

    Is there a way to have this implemented with the {all_field} code in the emails? So the date comes out as January 1, 2023.

    Reply
  4. Joe Machin
    Joe Machin August 21, 2022 at 3:30 pm

    How do I get this plugin? I’ve tried downloading it, but it’s not working. I looked in my Perks and I do not see Gravity Forms Conditional Merge Tags.

    Reply
    1. Samuel Bassah
      Samuel Bassah Staff August 22, 2022 at 9:42 am

      Hi Joe,

      This is a code snippet and not a complete perk so it won’t show up on the perks. To download the code snippet as a plugin, you’ll have to enter a valid email address. The download won’t work if you enter a fake email address. If you also, don’t want to enter your email address you can click on the View Code button to copy and paste the code snippet into your Theme’s funciton.php file and use it.

      Best,

  5. Mathieu Collet
    Mathieu Collet March 22, 2022 at 1:14 pm

    Hi ! This plugin is wonderful but I get the format in Englsih. My wordpress is in French, the related forms and entries are all in French but the formatted date is in English. How can I solve this? Kind regards

    Reply
  6. Richard
    Richard November 3, 2021 at 1:28 pm

    I don’t think this takes into account that you can format dates dd/mm/yyyy in the forms. A date saved in that format of 03/11/2021 becomes 11/03/2021 with this plugin.

    How can that be fixed?

    Reply
    1. Richard
      Richard November 3, 2021 at 1:51 pm

      Yeah just checked. The strtotime() function is assuming US format which isn’t the case. Changing the formatting of a date field to dash-separated solved the issue but I think the plugin needs to support dd/mm/yyyy formats as GF does.

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.

Download Plugin

Display Captured Dates in Any Format with Gravity Forms

This field is for validation purposes and should be left unchanged.