3

Can anyone tell me how to format \today to 'DD MMM YYYY' format?

Something that gives '10 Jun 2021' would be ideal but I can work with '10 JUN 2021'.

I have looked in all the suggested answers but none of them really works.

For example the answer to this one...

How to format \today to DD-MMM-YYYY format?

...is from 2017 and doesn't seem to be compatible with this line:

\usepackage[english]{babel}

...which I am using and would prefer to leave alone unless there is a compelling reason.

4
  • Welcome to TeX SX! Which month requires 3 digits?
    – Bernard
    Dec 30, 2021 at 23:08
  • @Bernard The three letter abbreviation is wanted.
    – egreg
    Dec 30, 2021 at 23:14
  • Please, can you make a minimal example of what you attempted to do?
    – egreg
    Dec 30, 2021 at 23:17
  • @egreg: It seems I skimmed through the question and misunderstood it. Thanks!
    – Bernard
    Dec 30, 2021 at 23:33

1 Answer 1

1

Have you tried the datetime2 package?

\documentclass{standalone}
\usepackage[english]{babel}
\usepackage[calc]{datetime}
\renewcommand{\today}{\twodigit{\the\day}\ \shortmonthname[\month] \the\year}

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

enter image description here

8
  • Thanks, but when I paste in (only) your exact code, I see the following error: ! LaTeX Error: Unknown option calc' for package datetime'. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.560 \if@dt@nodate ? Apologies for the formatting of the comment- not sure how to make this better!
    – Bob Macrae
    Dec 30, 2021 at 23:51
  • 2
    @BobMacrae: make sure you are using the datetime2 package (not datetime). I fixed this in the answer.
    – jak123
    Dec 30, 2021 at 23:58
  • 1
    Interesting - I tried datetime2 but it didn't work (I will try again). But I have just 'fixed' it by removing the [calc] - it then seemed to work with datetime. I'm new to this and now I have to work out why '\documentclass{standalone}' is giving me a grey page - my previous attempts have all been using '\documentclass[12pt]{article}' which gives a white page. Lots of learning!
    – Bob Macrae
    Dec 31, 2021 at 0:02
  • 1
    Please replace the standalone with your actual document class (report etc). This is just for testing purposes.
    – jak123
    Dec 31, 2021 at 0:05
  • Ah ha! Yes, it's working now - many thanks! (Please note that this is with ' \usepackage{datetime}')
    – Bob Macrae
    Dec 31, 2021 at 0:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .