Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

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

share|improve this question
4  
See here ctan.org/pkg/datetime From the documentation (pg 10) we have The option yyyymmdd makes \today produce YYYY/MM/DD date –  Sigur Jan 4 at 13:30
add comment

3 Answers

up vote 32 down vote accepted

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

share|improve this answer
1  
Somebody should check whether ISO 8601 says that the separator has to be - or --. (iso.org/iso/home/standards/iso8601.htm). Definitely YYYY/MM/DD should not be used - that would violate the standard. Keith –  KeithB Jan 8 at 9:53
    
@KeithB, Wikipedia claims, “The separator used between date values (year, month, week, and day) is the hyphen”. Also, it’s unlikely the standard mandates characters encoded neither in EBCDIC nor ASCII. –  J. C. Salomon Jan 13 at 19:20
add comment

According to the link of Sigur:

\usepackage{datetime}
\newdateformat{specialdate}{\THEYEAR-\twodigit{\THEMONTH}-\twodigit{\THEDAY}}
\date{\specialdate\today}
share|improve this answer
add comment

Use the package isodate

\usepackage[iso,german]{isodate}

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.