2

I have searched the isodate package and the datetime2 package to answer my question. I would like my date to be mm/dd/yyyy. The closest I have gotten is to have the date as dd/mm/yyyy. Could someone help me out.

I tried:

\usepackage[american,useregional=numeric]{datetime2}
\dateinputformat{american}
2
  • I would like to do this using the \today
    – Joe Ciras
    Commented Jan 21, 2016 at 16:24
  • With your code, I get 1/21/2016
    – egreg
    Commented Jan 21, 2016 at 16:41

1 Answer 1

3

You should pass the American english (USenglish) and numeric format options to isodate. This yields the output format mm/dd/yyyy:

01/21/2016

\documentclass{article}
\usepackage[USenglish,num]{isodate}
\begin{document}
\today
\end{document}

The same output under datetime2 (without defining your own date style):

\documentclass{article}
\usepackage[datesep={/}]{datetime2}
\DTMsetdatestyle{mmddyyyy}
\begin{document}
\today
\end{document}

Without any packages, you can just manage the printing yourself using \day, \month (in two-digit format) and \year explicitly:

\documentclass{article}

\makeatletter
\renewcommand{\today}{\two@digits{\number\month}/\two@digits{\number\day}/\number\year}
\makeatother

\begin{document}
\today

\end{document}

For calculations (like a two-digit year) on the date you can use the following:

01/21/16

\documentclass{article}

\usepackage{xparse}
\ExplSyntaxOn
  \cs_new_eq:NN \calc \fp_eval:n
\ExplSyntaxOff
\makeatletter
\renewcommand{\today}{%
  \two@digits{\number\month}/% MM
  \two@digits{\number\day}/% DD
  \calc{\number\year-100*trunc(\number\year/100,0)}}% YY
\makeatother

\begin{document}
\today

\end{document}
5
  • You can set both separators in one go with datesep={/} if you like. Commented Jan 21, 2016 at 18:20
  • The datetime2 suggestion above worked. The isodate solution still returned dd/mm/yyyy.
    – Joe Ciras
    Commented Jan 21, 2016 at 19:44
  • @JoeCiras: Not sure why. I've added a no-package option as well.
    – Werner
    Commented Jan 21, 2016 at 20:32
  • @Werner Just an additional question - in the manage yourself solution, how do you just have a two digit year? mm-dd-yy. I tried added \two@digits before the year statement but it looks like that command makes a one digit number a two digit number and does not truncate the date down to just two digits. Sorry for asking so many questions on this subject. I am new to customizing LaTeX.
    – Joe Ciras
    Commented Feb 4, 2016 at 11:46
  • @JoeCiras: See my updated answer.
    – Werner
    Commented Feb 5, 2016 at 2:08

You must log in to answer this question.

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