5

I'm currently using

\usepackage[UKenglish]{babel}
\usepackage{datetime}

and I'm getting Sunday 4th September, 2016

with the commands \today or with \newdate{example}{01}{09}{2016} (outside of \begin{document}) and \displaydate{example} inside the document.

How can I reformat this date to not have the name of the day in it (Best would be with using datetime2)? So like 4th September, 2016. With the "th" as a high letter like this: enter image description here

Full document example:

\documentclass[a4paper, 12pt, DIV=calc, headings=small]{scrreprt}
%Used packages
\usepackage[UKenglish]{babel}
\usepackage[utf8]{luainputenc}
\usepackage{datetime}

%Other definitions
\pagenumbering{arabic}

\newdate{sample}{31}{01}{2017}


\begin{document}
\displaydate{sample}\\
\today
\end{document}
  • 1
    Welcome to TeX.SX. Please post a compilable document, since we don't know which command was used by you to show the date at all. – user31729 Sep 4 '16 at 16:24
  • 1
    It is a fragment only, so far. Please post a document, not just macro calls – user31729 Sep 4 '16 at 16:31
5

Since you asked for a datetime2 solution:

\documentclass{article}

\usepackage[UKenglish]{babel}
\usepackage[useregional]{datetime2}

\DTMlangsetup[en-GB]{ord=raise,monthyearsep={,\space}}

\DTMsavedate{sample}{2017-01-31}

\begin{document}
\DTMusedate{sample}

\today

\end{document}

Produces

31st January, 2017 4th September, 2016

Requires datetime2 (base code) and datetime2-english (for en-GB style).

1

The name of day is defined with the macro \dayofweekname, you can simply deactivate it with \renewcommand{\dayofweekname}[3]{\relax}

Code

\documentclass[a4paper, 12pt, DIV=calc, headings=small]{scrreprt}
%Used packages
\usepackage[UKenglish]{babel}
\usepackage[utf8]{luainputenc}
\usepackage{datetime}
%Other definitions
\pagenumbering{arabic}

\newdate{sample}{31}{01}{2017}

\renewcommand{\dayofweekname}[3]{\relax}

\begin{document}
\displaydate{sample}\\
\today
\end{document}

Output

enter image description here

  • 4
    It's simpler to just use the nodayofweek package option. – Nicola Talbot Sep 4 '16 at 17:06

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.