Any way to add ordinal suffix to day values?

I want to be able to add the ordinal suffixes for day of month values in templates, but since I don’t have an actual date, how do I do that? For example:
Your Invoice will be sent on the 1st of the month, and payment is due on the 15th of the month. Can you create custom functions?

Need this kind of logic:


can you please make a screenshot of some invoice, hide private data and show us on that screenshot what you mean?

It’s more for the welcome emails and reminder emails. I need to add the appropriate suffix on all day of month numbers or else it’s not proper English.

“Your bill is due on the 1 day of month”
“Your bill is due on day 1 of the month”
Are both incorrect, I need:
“Your bill is due on the 1st of the month”

In php you can get that with a date formatter, but these aren’t date values, they are just numbers, so it would need a custom function, like the one at that link. Is there a way to add custom functions? Or could there be?

something like this

{% set testing_day = 15%}
{% set testing = testing_day~"now"|date(".m.Y")%}

Testing on {{testing_day}}{{ testing|date("S") }}

I think that will work and will try it out as soon as I can, thanks.