datetime2 package FAQ
You can use the options that are provided by the style for minor modifications, such as the example given in How do I make the date appear in my regional format instead of the default ISO format? If you have a more significant change that can’t be obtained through the style options, then you can define your own style.
For example, suppose you want the date in the form 2021-Aug-01. This has the year at the start but it uses an abbreviated English month name and a two-digit day. This format can’t be obtained with any of the styles provided by datetime2-english, so a new style is needed.
First you need to make sure that the English month name commands are provided, so you need to load datetime2 with en
(the ISO language code for English), but you don’t want to switch to that style so you also need useregional=false
:
\usepackage[en,useregional=false]{datetime2}Now you can define a style that uses the English commands:
\DTMnewdatestyle {yyyyMonthdd}% label {% style commands \renewcommand{\DTMdisplaydate}[4]{% \number##1 % year -% separator \DTMenglishshortmonthname{##2}% abbreviated month -% separator \DTMtwodigits{##3}% two-digit day }% \renewcommand{\DTMDisplaydate}[4]{% \DTMdisplaydate{##4}{##3}{##2}{##1}% }% }Remember that you need to set the style once it’s defined:
\DTMsetdatestyle{yyyyMonthdd}
2023-04-14 10:07:16
Permalink: https://www.dickimaw-books.com/faq.php?id=255
Alternative link: https://www.dickimaw-books.com/faq.php?itemlabel=datetime2adjustregional
Category: datetime2 package
Topic:
Localisation