# Redefinition of \today -- Clash with babel

I want my calendar dates to be formatted like DD.MM.YYYY

As I am from germany I use \usepackage[ngerman]{babel}. babel breaks my redefinition of \today to use leading zeros and I don´t know why it is not possible for me to redefine it. If babel is commented out, it works fine. But defining a new command which produces the desired format is possible, see the MWE below. Can someone explain why it is not possible to redefine \today? And is it safe to redefine it or might I break some things up that rely on \today so that it would be wiser to \todayx?

MWE

\documentclass{scrbook}
\usepackage[ngerman]{babel}
\begin{document}
\today \\
\todayx
\end{document}

• Sorry, but how would you like the date to be formatted? As \todayx? Aug 23, 2016 at 15:47
• Yes exactly, \todayx gives me what I want but it would be nicer to use \today (in my opinion).
– Enno
Aug 23, 2016 at 15:50
• Use datetime or datetime2 package and your formatting issues will be solved, I think
– user31729
Aug 23, 2016 at 15:50
• @ChristianHupfer I was posting an answer with datetime, but is datetime2 supposed to be the new version? Aug 23, 2016 at 15:53
• @Alenanno: Yes, but I never used it so far... I don't know the real differences there
– user31729
Aug 23, 2016 at 15:55

babel does definitions right at the start of \begin{document}, so even if \today is redefined after \usepackage{babel} this is not sufficient, but placing it in the \AtBeginDocument - hook will work. This does not require extra packages (although there nice packages such as datetime or datetime2!)

\documentclass{scrbook}
\usepackage[ngerman]{babel}

\AtBeginDocument{%
}
\begin{document}
\parindent=0em
\today

\todayx
\end{document}


• Nice. So I guess it doesn't matter where you place the redefinition as long as babel is loaded? Aug 23, 2016 at 15:58
• @Alenanno: No, I don't think so, since babel's \AtBeginDocument stuff is placed later then, overwritting the O.P. versions of \today ...
– user31729
Aug 23, 2016 at 15:59
• Christian is right, simply moving my commands behind \begin{document} also solves the issue (but is not a good solution indeed ;-) )
– Enno
Aug 23, 2016 at 16:02
• @Enno: That is possible too, of course, but for more general features, \AtBeginDocument (say in package or class code), is the better approach
– user31729
Aug 23, 2016 at 16:40
• @Christian: I definitely agree with you on that point.
– Enno
Aug 23, 2016 at 16:48

You can load the datetime package with the ddmmyyyy option and \renewcommand{\dateseparator}{.} for the separator.

## Code

\documentclass{scrbook}
\usepackage[ngerman]{babel}
\usepackage[ddmmyyyy]{datetime}
\renewcommand{\dateseparator}{.}

\setlength{\parindent}{0cm}

\begin{document}
Today: \today

Todayx: \todayx
\end{document}


Just for completeness, here's the datetime2 solution, but note that although it's using one of the base numeric styles it also requires datetime2-german (which is implicitly loaded) to prevent interference from babel.

\documentclass{scrbook}

\usepackage[ngerman]{babel}
\usepackage[style=ddmmyyyy,datesep=.]{datetime2}

\begin{document}
\today
\end{document}


Produces: