2

I am using the datenumber package in \LaTeX for something else but the output has a format of (month day, year), i.e. January 29, 2020. I would like to change it to 29 January 2020 or 2020 January 29. I can't find a way to change it using the datenumber package. Does anyone know? Thank you.


Edit: I am using this code: https://tex.stackexchange.com/a/505895/205680 and want to change the output date format. Thank you.

2 Answers 2

1

You can use the english option, which sets a date in the format "day month year" (where day is ordinal):

enter image description here

\documentclass{article}

\usepackage[english]{datenumber}

\begin{document}

\datedate

\end{document}

Alternatively, just define \datedate to meet your needs:

enter image description here

\documentclass{article}

\usepackage{datenumber}

\def\datedate{\thedateday~\datemonthname \space\thedateyear}

\begin{document}

\datedate

\end{document}

\datedate prints the current date, even if this is manually updated/set to something else (as in Next Wednesday's date), so it's not only restricted to the current date.

5
  • Hello. Thank you for responding. The first part works well except the fact that it has "th" on the day. I don't think the second part will work since I am not calling the date today but a date in the future. Jan 30, 2020 at 3:33
  • @icanseemyhalo: Show how you use it and we can work something out.
    – Werner
    Jan 30, 2020 at 6:35
  • I am using this code: tex.stackexchange.com/a/505895/205680 and want to change the output date format. :) Jan 30, 2020 at 8:35
  • @icanseemyhalo: Adding \renewcommand{\datedate}{\thedateday~\datemonthname \space\thedateyear} to the linked post shows the date in DMMMYYYY format, as you want. If you're still not satisfied, post your code on Pastebin so I can take a look at it.
    – Werner
    Jan 30, 2020 at 15:38
  • This works! Thank you so much! Could you edit your comment and include this for other people will see it immediately. Thank you again. :) Jan 30, 2020 at 16:55
0

Use datetime2 and create a new style:

enter image description here

\documentclass{article}

\usepackage[calc,english]{datetime2}

% Date/time style:
% <dow> <dayofmonth>. <monthname> <yyyy>, <hh>:<mm>:<ss> <ampm> CET
% Example: Saturday 25. February 2017, 01:24:01 PM CET
\DTMnewdatestyle{mydatestyle}{%
  % \DTMdisplaystyle{<YYYY>}{<MM>}{<DD>}{<dow>}
  \renewcommand{\DTMdisplaydate}[4]{%
    \DTMsettimestyle{mytimestyle}% Set the time style
    \DTMweekdayname{##4}% Day of week
    \space
    ##3% Day of month
    . % Period
    \DTMmonthname{##2}% Month of year
    \space
    ##1% Year
    , % Comma
    \DTMcurrenttime
  }%
  \renewcommand{\DTMDisplaydate}{\DTMdisplaydate}%
}

\DTMnewtimestyle{mytimestyle}{%
  % \DTMdisplaytime{<hh>}{<mm>}{<ss>}
  \renewcommand{\DTMdisplaytime}[3]{%
    \def\THEHOUR{##1}\def\THEAMPM{AM}% Assume AM
    \ifnum##1>12
      \edef\THEHOUR{\number\numexpr##1-12}% Correct for...
      \edef\THEAMPM{PM}%                    ...PM
    \fi
    \DTMtwodigits{\THEHOUR}% <hh>
    :%
    \DTMtwodigits{##2}% <mm>
    :%
    \DTMtwodigits{##2}% <ss>
    \space
    \THEAMPM% AM/PM
    \space
    CET% CET
  }%
}

\begin{document}

\DTMsetdatestyle{mydatestyle}

Today is \today.

\end{document}

Thanks to @Werner -- https://tex.stackexchange.com/a/396700/197451

1
  • Hello. Thank you for answering but this will not be able to change the output of my request. I'm sorry. I will edit my question. Jan 28, 2020 at 2:47

You must log in to answer this question.

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