Current Time Merge Tags in Gravity Forms (2024)

Current Time Merge Tags in Gravity Forms (1)Scott Ryer

/Updated January 10, 2023 /6 Comments

Automatically populate the current time into a field, confirmations, and notifications.

Current Time Merge Tags in Gravity Forms (2)

Insert the Current Time into Fields

Gravity Forms has included built-in merge tags to populate the current date into a field for quite a while: {date_mdy} and {date_dmy}. These are great for setting the default value in a Date field, including the date in a Single Line Text field’s value, or including the date in a confirmation or notification. Anyone familiar with Gravity Forms has probably used them extensively. I know that I sure have.

With the release of Gravity Forms 2.6.1, a new merge tag has been added to expand on this feature: {today}. The {today} merge tag allows you to insert the current date or time into all of the same places {date_mdy} is supported.

This includes things like inserting the current time into a field. I like to do this with order forms or any form where I’m using Date Time Calculator to do time calculations.

  1. Insert the Current Time into Fields
  2. Using the Merge Tag
    1. Prerequisites
    2. Merge Tags for the Current time
  3. Formatting Dates
  4. Taking It Further

Using the Merge Tag

Prerequisites

Confirm that you haveGravity Forms 2.6.1installed and activated.

Merge Tags for the Current time

The {today} merge tag’s default output is the current date, but with the addition of the :format merge tag modifier, you can output the current time in various formats.

Merge TagOutput
{today:format:h}12-hour format of an hour with leading zeros.
{today:format:H}24-hour format of an hour with leading zeros.
{today:format:i}Minutes with leading zeros.
{today:format:A}Uppercase Ante meridiem and Post meridiem.

Insert these into a Time field’s Default Value to automatically populate the current time into the Time field when the form is loaded.

Formatting Dates

The formatting options for the {today} merge tag also work for the current date, giving you lots of flexibility for displaying the current date anywhere on your form, confirmations, or notifications.

Merge TagOutput
{today}March 15, 2022
{today:format:Y-m-d}2022-03-15
{today:format:m/d/y}03/15/22
{today:format:d/m/Y\ \a\t\ H\:i\:s}15/03/2022 at 08:18:11
{today:timestamp}1647332291

Taking It Further

There are numerous options for formatting the current date with {today}, however those formatting options don’t apply to captured dates. For example, say you have a Date field on your form asking the user for their birth date. Use our Display Captured Dates in Any Format plugin to change the formatting for those captured dates. This gives you tons of flexibility in confirmations, notifications, or anywhere you want to output the Date field’s value using merge tags.

Did this resource help you do something awesome with Gravity Forms?

Then you'll absolutely love Gravity Perks; a suite of 47+ essential add-ons for Gravity Forms with support you can count on.

View All PerksBuy Now

    1. Current Time Merge Tags in Gravity Forms (5)

      Samuel BassahStaffFebruary 9, 2024 at 10:05 am

      Hi Dan,

      That format modifier works for current time merge tag. We have a snippet you can use to output selected dates in any format. Here’s the documentation with a link to the snippet and details on how it works. For your use case, the merge tag to get the year of the selected date will be like so; @{:5:Y}.

      Best,

  1. Current Time Merge Tags in Gravity Forms (6)

    MufutauApril 29, 2022 at 1:42 pm

    can this be used for current day like. Eg. Monday , Tuesday etc

    Reply

  2. Current Time Merge Tags in Gravity Forms (8)

    Jake JacksonApril 13, 2022 at 6:40 pm

    Gravity Forms 2.6.1 added support for the {today} merge tag which can handle all these use cases natively without any extra code (https://docs.gravityforms.com/today-merge-tags/). 🥳

    These are the comparable tags:

    {time_hh} = {today:format:h}{time_hh:12} = {today:format:h}{time_hh:24} = {today:format:H}{time_mm} = {today:format:i}{time_am_pm} = {today:format:A}

    {today} has the added benefit of allowing you to format the current date any way you want, too:

    {today} (March 15, 2022){today:format:Y-m-d}{today:format:d-m-Y}{today:format:m/d/y}{today:format:d/m/y}{today:format:m-Y}{today:timestamp}

    Dates/times a plenty!

    Reply

    1. Current Time Merge Tags in Gravity Forms (9)

      David SmithStaffApril 13, 2022 at 8:20 pm

      Great stuff, Jake! I saw this new merge tag but based on the PR I had understood that Richard had removed the custom format support. Glad I was mistaken as without it the merge tag is very much neutered. 😅

      We’ll update this article to spell out how the new {today} merge tag can be used for this use-case. 👍

Leave a Reply

Have a question?

We’re here to help, just send us a message.

Ask the Wizards

Recent Posts

  • Gravity Wiz Weekly 223
  • Spotlight: Building a Self-managed Lawyer Directory using Entry Blocks
  • Gravity Wiz Weekly 222
  • Workshop IX: Unlock Entry Blocks
  • Gravity Wiz Weekly 221

Categories

  • How To(96)
  • News(26)
  • Plugins(22)
  • Releases(31)
  • Resource(5)
  • Snippets(54)
  • Spotlights(32)
  • Tutorials(76)
  • Updates(223)
  • Workshops(4)

You might also like...

Post

How to Use Ready Classes in Gravity Forms

Read More

Post

Gravity Forms Field Value Extraction Techniques

Read More

Post

Read More

Current Time Merge Tags in Gravity Forms (2024)

References

Top Articles
Latest Posts
Article information

Author: Domingo Moore

Last Updated:

Views: 6550

Rating: 4.2 / 5 (53 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Domingo Moore

Birthday: 1997-05-20

Address: 6485 Kohler Route, Antonioton, VT 77375-0299

Phone: +3213869077934

Job: Sales Analyst

Hobby: Kayaking, Roller skating, Cabaret, Rugby, Homebrewing, Creative writing, amateur radio

Introduction: My name is Domingo Moore, I am a attractive, gorgeous, funny, jolly, spotless, nice, fantastic person who loves writing and wants to share my knowledge and understanding with you.