Dynamic Content API custom date functions

Hello there,

I am trying to create some relative date functions with the Dynamic Content API, but I’m honestly not sure where to start. I’m familiar with custom functions, can make my way around PHP, and have coded up some pretty awesome custom provider hooks, but I’m wanting to create dynamic content that lets me pass a strtotime() string into PHP and then turn it back into a date() format of my choosing.

For instance, I have the following PHP I’d like to replicate with dynamic content:

$thisWeekDate = strtotime("Monday this week");
$thisWeekStr = date("Y-m-d",$thisWeekDate);

I’d like to essentially be able to return this data by inputting the following dynamic content {{dc:date string="Monday this week" format="Y-m-D"}}.

Does that make sense and is that possible using the Dynamic Content API?

1 Like

It actually already uses strtotime if you use type="date" and you can keep your format part the same. However there isn’t a clear indication of that, or a UI selector for that so we will definitely add something like {{dc:date}} as you have used. See the below which uses the fallback to achieve this without that feature. Thanks for bringing this up, have a great day!

{{dc:fake fallback="Monday this Week" type="date" format="Y-m-d"}}

Wow! That’s awesome!! Works like a charm. Great workaround!!

1 Like

You are most welcome @bobbybosler

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.