2

What I'm getting now from \today is:

14th September 2018

How do I change it to:

14-Sep-2018

2
8

I think that the easiest way is to redefine \today to print this:

\documentclass{article}
\renewcommand\today{\number\day-%
  \ifcase\month \or Jan%
  \or Feb%
  \or Mar%
  \or Apr%
  \or May%
  \or Jun%
  \or Jul%
  \or Aug%
  \or Sep%
  \or Oct%
  \or Nov%
  \or Dec\fi-\number\year}%

\begin{document}

  \today

\end{document}

For completeness, here is the output:

enter image description here

3
  • 3
    +1 but what's wrong with \usepackage[yyyymmdd]{datetime} ? – user121799 Sep 15 '18 at 2:27
  • +1 because you didn't use an external package. :) – manooooh Sep 15 '18 at 2:41
  • @marmot I guess it’s all a question of what you know:) – user30471 Sep 15 '18 at 11:25
4

Here's how to do it with datetime2 and datetime2-english:

\documentclass{article}

\usepackage[en-GB]{datetime2}
\DTMlangsetup[en-GB]{daymonthsep={-},monthyearsep={-},ord=omit,abbr}

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

This produces:

15-Sep-2018

You can replace en-GB with any of the other English localisation styles that uses a day month year format. For example:

\documentclass{article}

\usepackage[en-MT]{datetime2}
\DTMlangsetup[en-MT]{daymonthsep={-},monthyearsep={-},ord=omit,abbr}

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

Your Answer

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