How to Customize Date Format in the Date Smart Tag


Would you like to customize the date format when using the Date Smart Tag? WPForms already has a built-in Smart Tag that will display the current date, but did you know you can actually define the format of this date and even display the current time as well?

This tutorial will walk you through the steps on how to customize the format on this Smart Tag and explain the process along the way.

Creating the form

For a more in-depth tutorial on how to use Smart Tags, please review this documentation.

In this tutorial, we’re going to create a form that has a Checkbox field which will ask the user to agree to the terms and conditions while placing a current date inside the label of the field.

In order to use Smart Tags in field labels, you’ll need to follow along the instructions from this tutorial.

Once you’ve gotten your form field labels set up to accept Smart Tags, you can now add a Checkbox form field to your form, inside the form field label, add {date format=”m/d/Y”} to be in the actual label.

To find a list of already added Smart Tags in WPForms, please review this documentation.

Add the checkbox form field to your form and inside the field label add the date smart tag

Customizing the Date Smart Tag

By default, when you use the Date Smart Tag, the format will automatically be applied as m/d/Y. PHP requires this format so it will know how to display the date in the correct format.

Let’s explain this default date format first. The month will be displayed in a numerical format with leading zeros (01-12), the day is also displayed in this same format with leading zeros (01-31) and finally the year, with this format of the capital letter Y, will be displayed in a full numerical representation with four digits.

the default format of the date smart tag is all numerical with two digit numbers and leading zeros for the month and day but year will be four digits

Now if we just change the format from m/d/Y to {date format=”Y-m-d H:i:s”} we’re now placing the year first, followed by the month and day but also we are including the time as well.

By altering the default format of the date you can pick and choose the date format you want for your smart tag per form and even per field

Once you’ve selected your PHP date format from the official PHP approved format list, you can easily customize the Date Smart Tag anywhere and everywhere on your forms.

Would you like to create a Smart Tag that will use the entry ID number of each form submission? Take a look at our tutorial on How to Create a Smart Tag for the Entry ID.