0

By default Latex formats the date as mmm d, yyyy, i.e. in the nonsensical middle endian format.
I would like to display it as d Mmm yyyy, e.g. 1 April 2018.

I've gone through the datetime2 documentation, but there is no dmmmyyyy option. I also have no luck using the babel package, because these is no english-za localization.

I would really like to avoid having to use the babel package, I have enough packages as is and I do not like the manipulations babel performs to the .aux file.

The following code illustrates the issue:

\documentclass[a4paper,english]{report}
\usepackage[english]{babel}
%I'd really like to just specify:
%\usepackage[d\space\Mmm\space\yyyy]{datetime2}
%So I can drop the day or rearrange things as needed
\usepackage[useregional]{datetime2}

%opening
\title{Test} 
\author{Johan}

\begin{document}
  \maketitle
\end{document}
4

The regionless english style defaults to the US style (to match the default \today provided by the LaTeX kernel). The datetime2-english module comes with a number of predefined English-speaking locales. It currently doesn't include South African, but the en-MT (Malta) locale matches your required format:

\documentclass[a4paper]{report}
\usepackage[en-MT]{datetime2}

\title{Test}
\author{Johan}

\begin{document}
  \maketitle
\end{document}

Test Johan 27 June 2018

You can also obtain them same result with some of the other locales. For example:

\documentclass[a4paper]{report}
\usepackage[en-GB]{datetime2}

\DTMlangsetup[en-GB]{ord=omit}

\title{Test}
\author{Johan}

\begin{document}
  \maketitle
\end{document}
1

The following fixes the issue:

\documentclass{article}
\usepackage[en-GB]{datetime2}

\let\oldtoday\today
\newcommand{\longtoday}{{\DTMlangsetup[en-GB]{abbr=false,ord=omit}\oldtoday}}
\newcommand{\shorttoday}{{\DTMlangsetup[en-GB]{abbr,ord=omit}\oldtoday}}
\renewcommand{\today}{{\longtoday}}

\title{test}

\begin{document}

\maketitle
%\longtoday

%\shorttoday

\end{document}

A simple alternative that does not use any packages (see: https://tex.stackexchange.com/a/112949/136037) is:

\documentclass{article}
\renewcommand{\today}{\ifnum\number\day<10 0\fi \number\day \space%
  \ifcase \month \or January\or February\or March\or April\or May%
  \or June\or July\or August\or September\or October\or November\or December\fi \space%
  \number \year} 
\begin{document}
  \today
\end{document}
  • Rather than saving \oldtoday you could just use \DTMtoday instead (which is datetime2's actual definition of \today provided in case another package changes \today after datetime2). – Nicola Talbot Jun 28 '18 at 10:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.