How to get date ordinals in date format

I’m using the following date format:

 D MMMM YYYY

To display today’s date: 5 October 2017

I can do the following to add the ordinal:

 D\th MMMM YYYY

5th October 2017

But obviously this won’t work correctly for e.g. 1st October 2017

Is there a way?

No, I hope.
However, if there is one it will heavily depend on the locale, and as far as I can tell the many 'English (somehing)' locales may act differently. In the UK itself it is uncommon to use an ordinal mark in written dates. There may be thousands of excessively stubborn ways to write dates in the English speaking world.
Your D\th MMMM YYYY does not work for me with UI=locale=DocLanguage= English (UK). The h is taken for “hour”.

Adapted from Automatically add suffixes to ordinal numbers in OpenOffice or LibreOffice | YATB

=DAY(TODAY())&IF(OR(DAY(TODAY())={1;2;3;21;22;23;31}); CHOOSE(1*RIGHT(DAY(TODAY());1);"st";"nd ";"rd ");"th ") &TEXT(TODAY();"mmmm yyyy")

See also @Lupp’s answer at How to convert a number to an ordinal?

Should be

[NatNum12 D=ordinal-number]D" of "MMMM "of" YYYY