Working with date parameters

Several WunderAutomation parameter returns 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:

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 follow the PHP date() function. For example the sting Y-m-d would produce a date formated like this: 2020-05-12

Some common date and time formats:

Format stringDescriptionExample
l jSSimple text representation without monthMonday 12th
F j, YWordPress default dateMay 12, 2020
g:i aWordPress default time4:59 pm
F j, Y g:i aDate and time combined (WordPress default)May 12, 2020 4:59 pm
Y-m-d H:i:sDate and time using ISO 86012020-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 stringDescriptionResult
F 1, YFirst day of the monthMay 1 2020
F t, YLast day of the monthMay 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 12th 2020.

ModifierDescriptionReturn
+1 dayAdds one day. Note that both “day” and “days” workMay 13, 2020
1 dayAdds one day (the default is to add)May 13, 2020
-2 weeksSubtract 2 weeks. Note that both “week” and “weeks” works.April 28, 2020
-12 hoursSubtract 12 hours. Note that both “hour” and “hours” work.May 11, 2020
last tuesdayCalculates last Tuesday based on today being May 12, 2020 (also a Tuesday)May 5, 2020
next tuesdayCalculates next Tuesday based on today being May 12, 2020 (also a Tuesday)May 19, 2020

Date format reference #

Letter / codeDescriptionExample
dDay of month. Always 2 digits with leading zeros if needed01 to 31
DA three letter text representation of the weekdayMon, Tue, Sun
jDay of the month, without leading zeros1, 5, 31
l(lowercase ‘L’) Full text representation of the weedayMonday, Sunday
NISO-8601 numeric representation of the weekday.1 (Monday) to 7 (Sunday)
SEnglish ordinal suffix for the day of the month, 2 charactersst, nd, rd or th
wNumeric representation of weekday0 (Sunday) to 6 (Saturday)
zThe day of the year. Jan 1st is zero0 to 365
WISO-8601 week number of year, weeks starting on Monday1, 10 52
FA full textual representation of a month, such as January or MarchJanuary, March
mNumeric representation of a month, with leading zeros01 (January), 11 (November)
MA short textual representation of a month, three lettersJan, Feb, Dec
nNumeric representation of a month, without leading zeros1 to 12
tNumber of days in the given month28 to 31
LLeap year or not.1 for a leap year, 0 for non leap year
oISO-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
YA full numeric representation of a year, 4 digits2018
yA two digit representation of the year09
aLowercase Ante meridiem and Post meridiemam or pm
AUppercase Ante meridiem and Post meridiemAM or PM
BSwatch Internet time000 to 999
g12-hour format of an hour without leading zeros1 to 12
G24-hour format of an hour without leading zeros0 to 23
h12-hour format of an hour with leading zeros01 to 12
H24-hour format of an hour with leading zeros01 to 23
iMinutes with leading zeros0 to 59
sSeconds with leading zeros0 to 59
eTimezone identifierUTC, GMT, Atlantic/Azores
I(capital i) Whether or not the date is in daylight saving time1 for DST, 0 for standard time
ODifference to Greenwich time (GMT) without colon between hours and minutes+0200
PDifference to Greenwich time (GMT) with colon between hours and minutes+02:00
TTimezone abbreviationEST
Z
Timezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive.
-43200 to 50400

Powered by BetterDocs

Leave a Reply

Your email address will not be published. Required fields are marked *