Latest news 2024-07-03: Ebook sale (1st – 31st July 2024): short story cybercrime fiction Unsocial Media free; short story cybercrime fiction Smile for the Camera free; short story noir crime fiction I’ve Heard the Mermaid Sing free; crime fiction novel The Private Enemy US$1.99; illustrated children’s story The Foolish Hedgehog US$0.99.

datetime2 package FAQ

How do I make the date appear in my regional format instead of the default ISO format? 🔗

First, you need to make sure that you have the relevant datetime2 language module installed. For example, to display the date in the en-GB style (British English) you need to install the datetime2-english module using your TeX package manager. (This needs to be done in addition to installing datetime2.)

Next you need to ensure that datetime2 picks up the correct locale setting for your document. Unfortunately, this doesn’t always work (see Localisation with tracklang.tex).

You can explicitly set the locale in the datetime2 package option list. For example:

\usepackage[en-GB]{datetime2}
If the language has been loaded before datetime2 then you need to explicitly switch on regional support. For example:
\documentclass[british]{article}
\usepackage{babel}
\usepackage[useregional]{datetime2}
If you prefer a numeric regional style then you need useregional=numeric.

Each style comes with its own set of options that are relevant to the particular style. These should be set using \DTMlangsetup. For example:

\documentclass{article}
\usepackage[en-GB,en-US]{datetime2}

\DTMlangsetup[en-GB]{ord=raise,abbr,monthyearsep={,\space}}
\DTMlangsetup[en-US]{dayyearsep={,\space}}

\begin{document}
GB date: \DTMsetstyle{en-GB}\DTMdate{2021-06-31}.

US date: \DTMsetstyle{en-US}\DTMdate{2021-06-31}.
\end{document}
This produces:
GB date: 31st Jun, 2021.

US date: June 31, 2021.

2021-05-08 22:01:45


Permalink: https://www.dickimaw-books.com/faq.php?id=254
Alternative link: https://www.dickimaw-books.com/faq.php?itemlabel=datetime2useregional

Category: datetime2 package
Topic: Localisation