[Tex/LaTex] How to print dates in latex without defining them first

datetime

I want \date{2015-10-10} to print 10th October, 2015 or similar. I don't want to separate the date value from the place where it is inserted into the document.

Best Answer

Along the same lines as the other answer (save it and immediately print it in a macro), but using datetime2 for formatting:

\documentclass{article}
\usepackage[en-US]{datetime2}
\newcommand{\mydate}[1]{
    \DTMsavedate{newdate}{#1}
    \DTMusedate{newdate}
}
\begin{document}
\mydate{2015-10-10}

\mydate{2015-01-01}
\end{document}

Prints:

October 10, 2015

January 1, 2015

Related Question