Date format: YYYY-MM-DD

Currently I put the date in my document using: \date{\today}

How do I display the date in the YYYY-MM-DD format?

Solutions Collecting From Web of "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


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


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

enter image description here

According to the link of Sigur:


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\twodigits#1{\ifnum#1<10 0\fi\the#1}

The date in my format: \mydate.

Use the package isodate


It offers various options (and needs one of its language options) and commands to change the date format.

Use the package datetime2