# Insert arbitrary date

I want to simply insert an arbitrary date (in my case March 16, 2015) in a way that does not hard code the date format.

That is, I want something like

\insertdate{<year}{<month>}{day}

For example:

\insertdate{2015}{03}{16}

which with the English configuration can insert

March 16, 2015

... but with for example Norwegian settings (given that month names and style are available) can insert

16. mars, 2015

I do not need (or want) a reference to the date after it is inserted, only that the format is not hard coded. I've found this related question, but find it hard to believe that what I want cannot be done out of the box.

1. Is there a package that lets me insert a general date and formats the date based on locale settings?
2. Is there an easy way to change the locale settings for this package?
• Have you looked into the datetime package? – Mico Mar 7 '15 at 22:26

The datetime package can give you the desired result using \date<language> and \formatdate. A little example:

\documentclass{article}
\usepackage[italian,spanish,french,swedish,ngerman]{babel}
\usepackage[ddmmyyyy]{datetime}

\begin{document}

Auf Deutsch:

\datengerman{\today}

\datengerman\formatdate{16}{03}{2004}

\selectlanguage{swedish}
P\r{a} svenska:

\dateswedish\today

\dateswedish\formatdate{16}{03}{2004}

\selectlanguage{french}
En Fran\c{c}ais:

\datefrench\today

\datefrench\formatdate{16}{03}{2004}

\selectlanguage{spanish}
En espa\~nol:

\datespanish\today

\datespanish\formatdate{16}{03}{2004}

\selectlanguage{italian}
In Italiano:

\dateitalian\today

\dateitalian\formatdate{16}{03}{2004}

\end{document}


• That's exactly what I want for the second part of my question – but how do I insert an arbitrary date instead of \today (for example 2015-04-28)? EDIT: The documentation helped, \formatdate{〈day〉}{〈month〉}{〈year〉} seems to do what I want. Thank you so much! – Martin Lehmann Mar 7 '15 at 22:33
• @MartinLehmann You're welcome! I added to my updated answer an example using \formatdate. – Gonzalo Medina Mar 7 '15 at 23:39