Use the datetime
package:
\documentclass{article}
\makeatletter
\newcommand\FormatDate[3]{%
#1-\shortmonthname[#2]-\two@digits{#3}}
\makeatother
\usepackage{datetime}
\newdateformat{gregdate}{\FormatDate{\THEYEAR}{\THEMONTH}{\THEDAY}}
\newcommand\Demonstrate[3]{%
Date #1-#2-#3 formats as \FormatDate{#1}{#2}{#3}.\par}
\setlength\parindent{0pt}
\begin{document}
\Demonstrate{2015}{01}{01}
\Demonstrate{2015}{02}{02}
\Demonstrate{2015}{03}{03}
\Demonstrate{2015}{04}{04}
\Demonstrate{2015}{05}{05}
\Demonstrate{2015}{06}{06}
\Demonstrate{2015}{07}{07}
\Demonstrate{2015}{08}{08}
\Demonstrate{2015}{09}{09}
\Demonstrate{2015}{10}{10}
Today is {\gregdate\today}.
\end{document}
If you wish to rename months, you can redefine \shormonthnameenglish
to suit your needs. (You can patch other macros as used by babel
, if necessary; see dt-austrian.def
, for example.)
\renewcommand*{\shortmonthnameenglish}[1][\month]{%
\@orgargctr=#1\relax
\ifcase\@orgargctr
\PackageError{datetime}{Invalid Month number \the\@orgargctr}{Month
numbers should go from 1 (jan) to 12 (dec)}%
\or Jan%
\or Feb%
\or Mar%
\or Apr%
\or May%
\or Jun%
\or Jul%
\or Aug%
\or Sept%
\or Oct%
\or Nov%
\or Dec%
\else%
\PackageError{datetime}%
{Invalid Month number \the\@orgargctr}%
{Month numbers should go from 1 (jan) to 12 (dec)}%
\fi
}
datetime
package.