Recent news (2017-04-18): glossaries-extra v1.14 released.

# datetime2 package FAQ

 Search: Category: All datatool datetime datetime2 flowfram flowframtk fmtcount glossaries private-enemy probsoln regular expression Search Tips

This is the FAQ for the datetime2 package. See also the datetime2 package documentation.

## General

This is discussed in the datetime2 documentation but briefly there were issues with datetime.sty that couldn't be resolved without breaking backward-compatibility.

Top

### Why doesn't datetime2 recognise my language?

The language and regional settings are dealt with by the datetime2 modules, which must be independently installed. Check the datetime2-contrib listings. If your language is listed there you can install it. If it's not listed there, the appropriate language module is unavailable, in which case you have the following options: volunteer to write the module or persuade someone to write the module.

Top

### Can I still use the old datetime package?

Obsolete packages remain available in the CTAN obsolete tree. Your TeX distribution may not contain some obsolete packages. If this is the case, you will need to download datetime.sty from CTAN and manually install.

It's your choice if you want to continue to use an obsolete package, but you should be aware that any issues with unmaintained packages won't be fixed.

Top

### What are the main differences between datetime and datetime2?

The main changes are:
1. All commands except \today and \Today have a prefix to help prevent clashes with other date and time-related packages. For example, \DTMcurrenttime instead of \currenttime.
2. Commands like \today are expandable, which means you should be able to use them to write the date/time information to external files, use them in PDF bookmarks or use them in commands like \MakeUppercase. Styles should protect any fragile commands to assist with this. There may, however, be some supplementary styles in contributed packages that can't produce expandable dates or styles. In which case this should be mentioned in the documentation for those supplementary packages.
3. Language support is separated into independently installed and maintained modules. This means you only need to install the modules for your own language(s) rather than having to install everything.

Top

### How do I change my document from datetime.sty?

The default date format in datetime2.sty has changed to ISO so if your old document looked like:
\documentclass{article}
\usepackage{datetime}
\begin{document}
\today
\end{document}

then the date would be formatted in British English style: Saturday 28th March, 2015. If you simply replace datetime with datetime2:
\documentclass{article}
\usepackage{datetime2}
\begin{document}
\today
\end{document}

then the date would be formatted in ISO style: 2015-03-28. If you want to reproduce the British format you need to make sure you have also installed datetime2-english and load it using package options:
\documentclass{article}
\usepackage[en-GB,showdow]{datetime2}
\begin{document}
\today
\end{document}

This now displays the date in the style Saturday 28th March 2015, which is slightly different from the datetime.sty format. You can also use "british" instead of "en-GB", but take care if you try loading it as a document class option. If you try
\documentclass[british]{article}
\usepackage[showdow]{datetime2}
\begin{document}
\today
\end{document}

this once again produces the ISO format 2015-03-28 but you can now switch to the British style using \DTMsetstyle{en-GB} or do
\documentclass[british]{article}
\usepackage[useregional,showdow]{datetime2}
\begin{document}
\today
\end{document}

Similarly if you use babel:
\documentclass[british]{article}
\usepackage{babel}
\usepackage[useregional,showdow]{datetime2}
\begin{document}
\today
\end{document}

If you want the suffix as a superscript you need to add
\DTMlangsetup[en-GB]{ord=raise}

before you display the date. If you additionally want the comma you need to do:
\DTMlangsetup[en-GB]{ord=raise,monthyearsep={,\space}}

datetime2.sty uses different command names to datetime.sty (except for \today) and prefixes them all to prevent clashes with other packages. It also uses an ISO year month day way of specifying dates in command arguments to avoid confusion. For example
\formatdate{28}{3}{2014}% datetime.sty

needs to be replaced with
\DTMdisplaydate{2014}{3}{28}{-1}% datetime2.sty

or
\DTMdate{2014-3-28}% datetime2.sty

Note that \DTMdate isn't expandable (but can calculate the week day, if enabled) whereas \DTMdisplaydate is expandable (but can't calculate the week day).

Saving dates has similarly changed from:

\newdate{mydate}{28}{3}{2015}% datetime.sty

to
\DTMsavedate{mydate}{2015-03-28}% datetime2.sty

Using the dates has changed from:
\displaydate{mydate}% datetime.sty

to
\DTMusedate{mydate}% datetime2.sty


Top

### Is there an equivalent to datetime's \textdate and \oclock styles?

Yes, but you need to load the datetime2-en-fulltext package. Example usage:
\documentclass{article}
\usepackage[showdow]{datetime2-en-fulltext}
\begin{document}
Date: \today. Time: \DTMcurrenttime.
\end{document}

See the datetime2-en-fulltext documentation for further details.

Top

### I've written a new date/time style. How can I share it?

Put it in a package and upload it to CTAN. For the suggested CTAN directory use /macros/latex/contrib/datetime2-contrib/package name where package name is the name of your package. See also the end of section 5.2 "Defining New Styles" in the datetime2 manual. (The location in the datetime2.sty v1.0 documentation is incorrect. It will be fixed in the next version.)

Top

### Why is "showdow" a package option rather than a language option?

In order to show the day of week (showdow=true), the week day needs to be calculated for commands like \today and \DTMdate. This requires that the datetime2-calc.sty package is loaded. If showdow is used as a package option, it can automatically load datetime2-calc after datetime2 has finished loading, which saves you from remembering to load it. Since the datetime2-calc package additionally requires pgfkeys and pgfcalendar which adds to the overall document build time, it's not loaded unless required.

Top

### How do I add a test for the showdow setting to a style?

You can use the \ifDTMshowdow conditional to determine the showdow setting, but remember that the style should also check if the day of week index has been set to -1 (which indicates that the day of week name should be ignored for a specific use case). So when you redefine \DTMdisplaydate within \DTMnewstyle or \DTMnewdatestyle the test for the day of week name should look something like:
 \ifDTMshowdow
\ifnum##4>-1 % space needed after -1
% code that inserts the day of week name
% where the day of week index is given by ##4
\fi
\fi


Not all styles, including some of the language styles, implement the showdow option. Check with the documentation for the relevant package or language module.