In the docs it says:
Most date value used in Dynamic Content can be formatted as date in another format. Use
type="date
in your Dynamic content, then with theformat
property you can display the date format you are looking for. See the example below. Format uses PHP date formatting internally, see PHP format characters. Internally this uses strtotime, you can pass values likeMonday next week
and it will work dynamically.
{{dc:looper:field key="created_date" type="date" format="Y m d"}}
I’ve bolded the part that I don’t understand. The way it is phrased, it sounds like I could modify the dynamic content key by using a phrase like “monday next week” but there’s no example of the correct use. It says I can pass a value, but not how. It’s likely I don’t understand what “internally” means as it’s used here, and there is no keyword modification that can be done with dynamic content dates. (Only using core cornerstone DC, that is, not twig.)
For context, I was looking into this because I’d like to use {{dc:global:date}} and subtract or add 1 year so I can build queries to fetch last year, this year and next year without manually setting last year and next year, and the date key I’m using is stored as a meta value rather than the publication or modification date.
I know historically there were limitations to how dynamic dates are handled, but there have been so many very cool advances lately! and the docs don’t always keep up. (it happens!)
So is there a way to use strtotime rules to tell Global Date to use any time but right now?