Date format: YYYY-MM-DD

edit: As noted by @Sean Allred, datetime has been superseded by datetime2.

Using the package datetime with the option yyyymmdd as

\usepackage[yyyymmdd]{datetime}

you just change the value of \dateseparator to replace the default / by - (or -- if you want).

\renewcommand{\dateseparator}{--}

Also as noted by @Vincent, you can define your own date format.

enter image description here


My solution needs no packages. The only thing you need to know is that the primitive registers \day, \month and \year include the desired information:

\def\mydate{\leavevmode\hbox{\the\year-\twodigits\month-\twodigits\day}}
\def\twodigits#1{\ifnum#1<10 0\fi\the#1}

The date in my format: \mydate.

According to the link of Sigur:

\usepackage{datetime}
\newdateformat{specialdate}{\THEYEAR-\twodigit{\THEMONTH}-\twodigit{\THEDAY}}
\date{\specialdate\today}