I would like to be able to use, in the same document, these two date formats:
- dd/mm/yyyy (as default format)
- yymmdd (as "local" format)
Why I want that?
Because I would like to use the "local" format to define the document reference code (e.g. mydocumenttitle_yymmdd.pdf
) but in "normal" text, I would like to use the default dd/mm/yyyy
format with the command \today
.
First attempt
For the moment I wasn't able to do better than this:
\documentclass{article}
\usepackage{datetime}
\newdate{specialdate}{\day}{\month}{\year}
\usepackage[datesep={}]{datetime2}
\begin{document}
Format with dd/mm/yyyy: {\ddmmyyyydate\displaydate{specialdate}}
Format with yymmdd: \today
\end{document}
Which gives the following result:
But there are the following problems:
-
The
yymmdd
format is not correct because I achieve onlyyyyymmdd
. How to obtain the date format with only two digits for the year:yymmdd
? -
The use of command
\today
doens't give the default format but theyymmdd
one.
Is there a way to define\today
with the default format (i.e.dd/mm/yyyy
) and another command for the "local" format (i.e.yymmdd
)? -
It use the two packages
datetime
anddatetime2
.
Is it possible to use only one package?
Best Answer
Try this code.
The package
datetime
is obsolete. Onlydatetime2
is needed.Two styles have been defined to present the desired date formats --default (
ddmmyyyyx
) and local (yymmdd
)--.Using
\DTMsetstyle{<name>}
in the preamble sets the default style.