Formatting dates “day month year” with biblatex

36,940

Solution 1

Ah, a use for the australian language. Its date format is correct, so you can load it as a subsiduary language via babel and then wrap your bibliography in an otherlanguage environment:

Sample output

\documentclass{article}

\usepackage[australian,american]{babel}

\usepackage[backend=biber,dateabbrev=false]{biblatex}

\begin{filecontents}{references.bib}
@book{Book,
  title = {This is a Title},
  author = {Author, Some},
  location = {The City},
  publisher = {Publisher},
  date = 2005,
  month = feb,
  day = 14,
}
\end{filecontents}
\addbibresource{references.bib}

\begin{document}
\today

Citing \cite{Book}.

\begin{otherlanguage}{australian}
\printbibliography
\end{otherlanguage}

\end{document}

Solution 2

As the manual says :

The biblatex package always treats [english] as an alias for american. It is preferable to use the language identifiers american and british

you can use something like :

\documentclass{article}
\usepackage[british]{babel}
\usepackage[backend=biber,dateabbrev=false]{biblatex}
\begin{filecontents}{references.bib}
@book{Book,
title = {This is a Title},
author = {Author, Some},
location = {The City},
publisher = {Publisher},
date = 2005,
month = feb,
day = 14,
}
\end{filecontents}

\addbibresource{references.bib}
\begin{document}
\today
Citing \cite{Book}.
\printbibliography
\end{document}

or

\documentclass{article}

\usepackage[british]{babel}
\usepackage[babel=other,backend=biber,dateabbrev=false]{biblatex}
\begin{filecontents}{references.bib}
@book{Book,
  title = {This is a Title},
  author = {Author, Some},
  location = {The City},
  publisher = {Publisher},
  hyphenation = {british}
  date = 2005,
  month = feb,
  day = 14,
}
\end{filecontents}
\addbibresource{references.bib}
\begin{document}
\today
Citing \cite{Book}.
\printbibliography
\end{document}

enter image description here

Solution 3

You can use australian, but that also affects hyphenation, comma, and quotation rules in comparison to american (alias USenglish). If you just want to make the day come before the month (in both long and short dates), you should just change the way the dates are printed in the american/USenglish language. Note that this will change the date format of the entire document, rather than just the bibliography.

The simplest way is to insert this in the preamble:

\DefineBibliographyExtras{USenglish}{%

  % d-m-y format for long dates
  \protected\def\mkbibdatelong#1#2#3{%
    \iffieldundef{#3}
      {}
      {\stripzeros{\thefield{#3}}%
       \iffieldundef{#2}{}{\nobreakspace}}%
    \iffieldundef{#2}
      {}
      {\mkbibmonth{\thefield{#2}}%
       \iffieldundef{#1}{}{\space}}%
    \iffieldbibstring{#1}{\bibstring{\thefield{#1}}}{\stripzeros{\thefield{#1}}}}%

  % d-m-y format for short dates
  \protected\def\mkbibdateshort#1#2#3{%
    \iffieldundef{#3}
      {}
      {\mkdatezeros{\thefield{#3}}%
       \iffieldundef{#2}{}{/}}%
    \iffieldundef{#2}
      {}
      {\mkdatezeros{\thefield{#2}}%
       \iffieldundef{#1}{}{/}}%
    \iffieldbibstring{#1}{\bibstring{\thefield{#1}}}{\mkdatezeros{\thefield{#1}}}}%
}

I wrote the code with the alias USenglish, but you can replace that with american if you choose. They are two names for the same style. You need to be sure that it's the same alias used when calling \usepackage{babel}, though. (If you change the properties of USenglish, don't expect the changes to be carried over to american!)

A more elegant solution is to make an .lbx file to stay more organized and make this style easily accessible in future documents. The code only differs at the beginning and end. You need to add \ProvidesFile to the top and \endinput to the bottom. Then add two \Inherit... commands and change any \Define... commands to Declare... commands.

\ProvidesFile{USenglish-dmy.lbx}[USenglish localization with d-m-y format for dates]

\InheritBibliographyExtras{USenglish}
\DeclareBibliographyExtras{%

  % d-m-y format for long dates
  \protected\def\mkbibdatelong#1#2#3{%
    \iffieldundef{#3}
      {}
      {\stripzeros{\thefield{#3}}%
       \iffieldundef{#2}{}{\nobreakspace}}%
    \iffieldundef{#2}
      {}
      {\mkbibmonth{\thefield{#2}}%
       \iffieldundef{#1}{}{\space}}%
    \iffieldbibstring{#1}{\bibstring{\thefield{#1}}}{\stripzeros{\thefield{#1}}}}%

  % d-m-y format for short dates
  \protected\def\mkbibdateshort#1#2#3{%
    \iffieldundef{#3}
      {}
      {\mkdatezeros{\thefield{#3}}%
       \iffieldundef{#2}{}{/}}%
    \iffieldundef{#2}
      {}
      {\mkdatezeros{\thefield{#2}}%
       \iffieldundef{#1}{}{/}}%
    \iffieldbibstring{#1}{\bibstring{\thefield{#1}}}{\mkdatezeros{\thefield{#1}}}}%
}

\InheritBibliographyStrings{USenglish}
\endinput

Save this as USenglish-dmy.lbx and then add this in your preamble: \DeclareLanguageMapping{USenglish}{USenglish-dmy}. That's it! Now all dates should have the day before the month, and nothing else (e.g. hyphenation or quotation styles) is affected.

Thanks to moewe for this answer that helped me arrive at this solution.

Solution 4

One very simple way to change biblatex's date format so the day comes before the month is to add the option language=australian when loading biblatex. This has the following features:

  • Only affects the bibliography.
  • Doesn't require babel or polyglossia.
  • Doesn't require the use of any language commands when calling \printbibliography.
  • Explicitly choosing the language prevents biblatex from "guessing" incorrectly.

Call the option like this (see line 2):

\documentclass{article}
\usepackage[backend=biber,dateabbrev=false,language=australian]{biblatex}

\begin{filecontents}{references.bib}
@book{Book,
title = {This is a Title},
author = {Author, Some},
location = {The City},
publisher = {Publisher},
date = {2005-02-14},
}
\end{filecontents}

\addbibresource{references.bib}
\begin{document}
\today

Citing \cite{Book}.
\printbibliography
\end{document}

Output example showing dd Month YYYY in bibliography but Month dd, YYYY for "\today"


You could use UKenglish (alias british) instead of australian; you will then get "14th" instead of "14". Please note, however, that using either british or australian will also change the style of hyphenation, serial commas, and quotation marks in comparison to USenglish (alias USenglish).

The language option is explained in section 3.1.2.1 of the biblatex documentation (ver. 2.8a):

This option controls multilingual support. When set to autobib, autocite or auto, biblatex will try to get the main document language from the babel/polyglossia package (and fall back to English if babel/polyglossia is not available). It is also possible to select the document language manually.

Solution 5

For user of polyglossia the relevant information is available elsewhere on this site but I had difficulties finding it, so I add this here to link to the relevant answers:

Due to a bug in polyglossia it is not possible to set language-variants in a way that is available to e.g. biblatex. Thus \selectlanguage[variant=australian,ordinalmonthday=false]{english} will make \today produce "24 May 2018" but \printbibliography will still render US-style dates ("May 24, 2018").

But it is now possible with \DeclareLanguageMapping{english}{australian} to make biblatex use the right format.

Share:
36,940

Related videos on Youtube

Ruben Verborgh
Author by

Ruben Verborgh

Updated on May 25, 2020

Comments

  • Ruben Verborgh
    Ruben Verborgh over 3 years

    What is the correct way to have “day month year” formatting in biblatex?

    Given this document:

    \documentclass{article}
    \usepackage[backend=biber,dateabbrev=false]{biblatex}
    
    \begin{filecontents}{references.bib}
    @book{Book,
      title = {This is a Title},
      author = {Author, Some},
      location = {The City},
      publisher = {Publisher},
      date = 2005,
      month = feb,
      day = 14,
    }
    \end{filecontents}
    \addbibresource{references.bib}
    
    \begin{document}
    Citing \cite{Book}.
    \printbibliography
    \end{document}
    

    The bibliography reads:
    [1] Some Author. This is a Title. The City: Publisher, February 14, 2005.

    However, I would like:
    [1] Some Author. This is a Title. The City: Publisher, 14 February 2005.

    Can I do that without fiddling with \printdate?
    The manual mentions that the date format is language-specific, yet I do want to continue in American English, just with a “day month year” style in the bibliography.

  • Ruben Verborgh
    Ruben Verborgh about 10 years
    Creative solution :-)
  • Ruben Verborgh
    Ruben Verborgh about 10 years
    I noted that reversing the order of australian and english messes up my hyphenation. Out of curiosity, could you explain why?
  • Andrew Swann
    Andrew Swann about 10 years
    The last language that you specify is the one that becomes the default for the document. In the babel definition files "australian" is a dialect of "british" and so uses "british" hyphenation rather than "american". Avoid using the generic "english" it is not always obvious which variant it points to.
  • Ruben Verborgh
    Ruben Verborgh about 10 years
    Yeah, I noticed a warning about english so I put american now. Seems a strange choice to have the last one be the default, but it works. Thanks for your help!
  • Andrew Swann
    Andrew Swann about 10 years
    Actually in the newer versions you can write \usepackage[main=american,british]{babel} explicitly specifying the main language.
  • Christian
    Christian about 10 years
    So is the only difference between british and australian the date format? Then I'd change my document to australian, too, I guess because I'm not a particular fan of "20th September" in writing (but much less so of American mixed-endian).
  • Andrew Swann
    Andrew Swann about 10 years
    @Christian Yes, (currently) the only difference in babel's english.ldf between british and australian is the date format. However, there may be documentclasses or style files out there that make other distinctions between the two.
  • Cerran
    Cerran over 9 years
    It should be noted that using the language australian changes much more than the date format in comparison to american (alias USenglish). It also changes hyphenation rules, serial comma use, type of quotation marks used, and the relative positions of quotation marks and end-punctuation.
  • Florian
    Florian over 5 years
    While your MWE certainly works, using polyglossia is not only not required but it seems to overrule the language= setting
  • moewe
    moewe over 5 years
    Currently: Try to avoid polyglossia if at all possible. If you are mainly writing in Latin script (and surely for (western) European languages) there is little need for polyglossia's extra features and babel works just fine. Even for some more complicated script systems babel is making progress. polyglossia on the other hand has not gotten a proper bug-fix release in ages (the April 2018 release was more of a maintenance release and did not address many open bug reports), see github.com/reutenauer/polyglossia/issues