Using date parameters

Several WunderAutomation parameters return a date. You can change how the date is returned in two ways. Using the format modifier to define how the date is represented in text, and the add parameter to change the actual date returned.

As with all parameters, the easiest way to write the parameter placeholder is to use the parameter editor:

img

Date format

The date format is determined as follows:

  • If the parameter placeholder has a format modifier, it will be used.
  • If not, the default date format in WunderAutomation settings will be used.
  • If no default date format is set, the WordPress default date format from Settings >> General Settings will be used.

The format is defined using a standard PHP date formatting string. The format follows the PHP date() function. For example, the sting Y-m-d would produce a date formatted like this: 2020-05-12

Some common date and time formats:

Format string Description Example
l jS Simple text representation without month. Monday 12th
F j, Y WordPress default date. May 12, 2020
g:i a WordPress default time. 4:59 pm
F j, Y g:i a Date and time combined (WordPress default). May 12, 2020 4:59 PM
Y-m-d H:i:s Date and time using ISO 8601. 2020-05-20 16:59

See the date format reference section below for details on what each letter in the date string represents.

Some common date formatting tricks

Assuming the parameter would have returned May 12, 2020. The following special formatting strings would return:

Format string Description Result
F 1, Y First day of the month. May 1, 2020
F t, Y Last day of the month. May 31, 2020

Adding or subtracting time

Using the add modifier, it’s possible to manipulate the returned date by adding or subtracting from it. This follows the syntax of the PHP strtotime() function. Some examples assuming that the original date returned from the parameter is 10:00 AM May 12, 2020.

Modifier Description Return
+1 day Adds one day. Note that both "day" and "days" work. May 13, 2020
1 day Adds one day (the default is to add). May 13, 2020
-2 weeks Subtracts 2 weeks. Note that both "week" and "weeks" work. April 28, 2020
-12 hours Subtracts 12 hours. Note that both "hour" and "hours" work. May 11, 2020
last tuesday Calculates last Tuesday based on today being May 12, 2020 (also a Tuesday). May 5, 2020
next tuesday Calculates next Tuesday based on today being May 12, 2020 (also a Tuesday). May 19, 2020

Date format reference

Letter/code Description Example
d Day of the month. Always two digits with leading zeros if needed. 01 to 31
D A three-letter text representation of the weekday. Mon, Tue, Sun
j Day of the month, without leading zeros. 1, 5, 31
l (lowercase ‘L’) A full textual representation of the weekday. Monday, Sunday
N ISO-8601 numeric representation of the weekday. 1 (Monday) to 7 (Sunday)
S English ordinal suffix for the day of the month, two characters. st, nd, rd or th
w Numeric representation of weekday. 0 (Sunday) to 6 (Saturday)
z The day of the year. Jan 1st is zero. 0 to 365
W ISO-8601 week number of year, weeks starting on Monday. 1, 10, 52
F A full textual representation of a month. January, March
m Numeric representation of a month, with leading zeros. 01 (January), 11 (November)
M A short textual representation of a month, three letters. Jan, Feb, Dec
n Numeric representation of a month, without leading zeros. 1 to 12
t The number of days in the given month. 28 to 31
L Leap year or not. 1 for a leap year, 0 for a non-leap-year
o ISO-8601 week-numbering year. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead. (added in PHP 5.1.0). 1999 or 2020
Y A full numeric representation of a year, four digits. 2018
y A two-digit representation of the year. 09
a Lowercase Ante meridiem and Post meridiem. am or pm
A Uppercase Ante meridiem and Post meridiem. AM or PM
B Swatch Internet Time. 000 to 999
g 12-hour format of an hour without leading zeros. 1 to 12
G 24-hour format of an hour without leading zeros. 0 to 23
h 12-hour format of an hour with leading zeros. 01 to 12
H 24-hour format of an hour with leading zeros. 01 to 23
i Minutes with leading zeros. 0 to 59
s Seconds with leading zeros. 0 to 59
e Timezone identifier. UTC, GMT, Atlantic/Azores
I (capital i) Whether or not the date is in daylight saving time. 1 for DST, 0 for standard time
O Difference to Greenwich time (GMT) without a colon between hours and minutes. +0200
P Difference to Greenwich time (GMT) with a colon between hours and minutes. +02:00
T Timezone abbreviation. EST
Z Timezone offset from UTC in seconds. -43200 to 50400