Documentation

gwp_date_field

From v1.2 this merge tag is deprecated (but still functional). You can use the gwp_date_format merge tag modifier to modify and format Date Fields and Text Fields with dates.

The gwp_date_field Merge Tag returns a modified date time relative to the date time of a field-value with a date/time string in the desired format.

{gwp_date_field id=5 modify="first day of next month" format="d-m-Y"}
SettingsInfo
id (required)ID of the field containing a date time value.
modify (optional)For available date time modifications, see https://www.php.net/manual/en/datetime.formats.relative.php.
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:

{gwp_date_field id=1 modify="first day of next month" format="d-m-Y"}

Using with Text Field

Example where field 1 is a Text Field:

{gwp_date_field id=1 field_format="Y-m-d \a\t\ H:i:s" field_timezone='UTC' format="d/m/Y\ \a\t\ H:i:s" timezone='Europe/Amsterdam'}

Try it

Last updated: 27-10-2022