0

I want \date{\today} to show the date in the format Month-year; without the day (i.e: July 2023), instead of: day of the week-day-Month, year (i.e.: Tuesday 18th July, 2023).

2 Answers 2

3

I used some information from the datetime2 manual and this answer.

  • define a new date style monthyear (using \DTMnewdatestyle)
  • set the style with \DTMsetdatestyle{monthyear}

Code

\documentclass{article}
\usepackage[english]{babel}
\usepackage{datetime2}

\DTMnewdatestyle{monthyear}{%
    % ##1 = year, ##2 = month, ##3 = day
    \renewcommand*{\DTMdisplaydate}[4]{\DTMenglishmonthname{##2} ##1}%
    \renewcommand*{\DTMDisplaydate}{\DTMdisplaydate}%
}

\begin{document}
\DTMsetdatestyle{monthyear}
This PDF was created on \today.
\end{document}

Result

enter image description here

1

The package datetime provides the function ,,longdate'':

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{datetime}

\begin{document}
    Today is:  \longdate \today
\end{document}

Today is: Tuesday 18th July, 2023

3
  • 1
    I'm not seeing how that answers the question.
    – Teepeemm
    Commented Jul 18, 2023 at 12:24
  • sorry, i mistook the format
    – Coliban
    Commented Jul 18, 2023 at 14:53
  • For the format in question simply write: \monthname[\THEMONTH] \THEYEAR
    – Coliban
    Commented Jul 18, 2023 at 15:00

You must log in to answer this question.

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