gwp_date_format
The gwp_date_format Merge Tag Modifier returns a modified date time relative to the date time of a field-value with a date/time string in the desired format.
{Date Field:1:gwp_date_format modify="first day of next month" format="d-m-Y"}
Settings | Info |
---|---|
modify (optional) | For available date time modifications, see https://www.php.net/manual/en/datetime.formats.php#datetime.formats.relative. |
field_format (optional for date fields, required for other fieldtypes) | Format of the input. For an explanation of available format options, see https://www.php.net/manual/en/datetime.format.php. Regular character can be escaped using a backslash \. For example: ‘d/m/Y\ \a\t\ H:i:s’. |
format (optional) | Format of output, default =’Y-m-d H:i:s’ |
field_timezone (optional) | Default is WordPress timezone setting |
timezone (optional, default is WordPress timezone setting) | For available timezones, see https://www.php.net/manual/en/timezones.php. Example: Europe/Amsterdam It is also possible to use an offset value: +0200 |
Using with Date Field
Example where field 1 is a Date Field:
{Date Field:1:gwp_date_format modify="first day of next month" format="d-m-Y"}
Using with Text Field
Example where field 2 is a Text Field:
{Text Field:2:gwp_date_format field_format="Y-m-d" field_timezone='UTC' format="d/m/Y\ \a\t\ H:i:s" timezone='Europe/Amsterdam'}
Try it
Since
The gwp_date_format modifier was added in 1.2.
Frequently Asked Questions
You can use the gwp_date_format modifier to output a Date field in your desired format. This is useful for showing dates in different styles — for example, 07-06-2025 or June 7, 2025.{Date Field:4:gwp_date_format format="d-m-Y"}
You can add a modify option to shift the displayed date by any relative amount — days, weeks, months, and more.{Date Field:4:gwp_date_format modify="+1 week" format="d-m-Y"}
{Date Field:4:gwp_date_format modify="-2 days" format="Y/m/d"}
If you’re using a Text field to store a date (for example, 2025-06-07), you can still use gwp_date_format. You must provide the field_format so it knows how to parse your text.{Text Field:1:gwp_date_format field_format="Y-m-d" format="d/m/Y"}
You can use the timezone option to control which timezone is used when displaying the date.{Text Field:1:gwp_date_format field_format="Y-m-d" modify="+2 days" timezone="Europe/Amsterdam" format="d-m-Y H:i:s"}
field_format tells GravityWP how to read the original value (needed for Text fields).
format tells GravityWP how to display the output value.
The modify option supports natural language phrases and advanced date math — not just simple day or week offsets. You can shift a date using flexible terms like:
– +1 week, -2 days
– next monday, last friday
– first day of next month, last day of -1 month
– third wednesday of this month
You can even combine these phrases or use dynamic values with nested merge tags:{Date Field:4:gwp_date_format modify="last monday" format="d-m-Y"}
{Date Field:4:gwp_date_format modify="*|Date Modifier:5|*" format="d-m-Y"}
This makes modify extremely powerful for working with deadlines, schedules, or user-defined logic
Last updated: 18-07-2025