# Date formatting: Changing from web format to another format

I have two different dates in my LaTeX document which are not current dates (dates which come in my LaTeX template from the web form). They look like this: 2016-03-31, but I want these dates be in the format dd/mm/yyyy. What I'm doing right now is using the package \usepackage[ddmmyyyy]{date time} and put inside the \date{} in my dates, but it doesn't change the format of the dates. How do I change the format of the dates correctly?

• How is the date typeset? You are free to typeset it the way you like, no matter if 2016-03-07 or 07th of march 2016 or 03.07.2016. Please clarify. – Johannes_B Mar 7 '16 at 12:57
• This is again a question by you that does not show the slightest effort :-( – user31729 Mar 7 '16 at 13:04

This works out the box. If - appears as the date separator there's probably a 'wrong'redefinition of \dateseparator.

Please note date datetime isn't developed further -- Nicola Talbot has published datetime2 about a year ago.

\documentclass{article}

\usepackage[ddmmyyyy]{datetime}
%\renewcommand{\dateseparator}{-}

\title{The Theory of Brontosaurs}
\author{Mrs. Ann Elk}
\date{\today}

\begin{document}
\maketitle
\end{document}


Update

Here's a version that transforms yyyy-mm-dd input into dd/mm/yyyy:

\documentclass{article}

\usepackage{xparse}

\ExplSyntaxOn
\newcommand{\changedate}[2][/]{%
\tl_set:Nx \l_tmpa_tl {#2}
\seq_set_split:NnV \l_tmpa_seq {-} {\l_tmpa_tl}
\seq_reverse:N \l_tmpa_seq
\seq_use:Nnnn \l_tmpa_seq {#1} {#1} {#1}
}
\ExplSyntaxOff

\title{The Theory of Brontosaurs}
\author{Mrs. Ann Elk}

\newcommand{\webdate}{2016-03-31}

\date{\changedate{\webdate}}

\begin{document}
%\changedate{\webdate}
\maketitle
\end{document}


• This example is good if date refers to the today date, but what if it's the date 31.03.2016, not today, how can I define this date? – Lucky_girl Mar 7 '16 at 14:10
• @Lucky_girl: \date{31/03/2016} ;-) Actually, you don't need \datetime at all if you want to fix the date already. \datetime changes the output format of \today, but \date{...} works without. – user31729 Mar 7 '16 at 14:14
• okay, but my date is in the format 2016-03-31 (it's just a text) in the document right now, can I change it automatically to the format 31/03/2016 ? – Lucky_girl Mar 7 '16 at 14:25
• @Lucky_girl: I don't understand. If it is text only you can change by hand. – user31729 Mar 7 '16 at 14:27
• @Lucky_girl: That's in principle not the job of \date or of datetime. If you would finally post a compilable example that clearly explains what the issue is this would be much easier -- it's not Quantum Field Theory!!! Now my work proves useless :-( – user31729 Mar 7 '16 at 14:32

\date doesn't try parsing its argument. It simply stores it and the stored value is inserted into the title page when you do \maketitle, so if you do \date{2016-03-31} then that's exactly what will appear. You need to either explicitly format it the way you want it, for example, \date{31/03/2016} (as the others have suggested) or wrap the ISO date in a command that can parse it. For example:

\documentclass{article}

\usepackage[datesep=/,style=ddmmyyyy]{datetime2}

\title{Sample}
\author{Me}
\date{\DTMdate{2016-03-31}}

\begin{document}
\maketitle

Another date: \DTMdate{2016-03-07}.

\end{document}


Produces:

The other alternative is to modify the way \maketitle works so that it parses the value of \@date, but that requires knowing something about what class and packages you are using. Without a minimal working example (MWE) we can't help further with that.