# Change date style when using regional settings in datetime2

I can't seem to change datetime2's settings when using the option useregional to display the date in the language given to babel

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[italian]{babel}
\usepackage[useregional]{datetime2}
%
\DTMnewdatestyle{mydatestyle}{
\renewcommand*{\DTMdisplaydate}[4]{##3 \DTMmonthname{##2}}
\renewcommand*{\DTMDisplaydate}{\DTMdisplaydate}
}
\DTMsetdatestyle{mydatestyle}
% -------------------
\begin{document}
\today
\end{document}


I'd like the output to be 08 settembre, with the leading zero in front of the 8 and without the year, but I'm still getting the default 8 settembre 2019.

What am I doing wrong?

Well, the main issues in your code are the following:

1. You need to use option calc for datetime2.
2. Use option useregional=text for datetime2.
3. Move command \DTMsetdatestyle{mydatestyle} after \begin{document}.
4. Use command \DTMtwodigits{##3} to get the leading zero ...

\documentclass[italian]{article}

\usepackage[T1]{fontenc}
\usepackage[italian]{babel}
\usepackage[%
useregional=text, % <=================================================
calc % <==============================================================
]{datetime2}

\DTMnewdatestyle{mydatestyle}{%
\renewcommand*{\DTMdisplaydate}[4]{\DTMtwodigits{##3} \DTMmonthname{##2}} % <============ year month day dow
\renewcommand*{\DTMDisplaydate}{\DTMdisplaydate}
}

\begin{document}

\DTMsetdatestyle{mydatestyle} % <=======================================
\today

\end{document}


and its result:

• wow, this is my third question in a row that you answer in the span of 12 hours! Thanks a lot Sep 8, 2019 at 15:57
• @noibe :-) You are welcome! Sep 8, 2019 at 15:59