5

It seems by loading the pdfcomment package, the date format is implicitly changed to YYYY-MM-DD. Consider the following MWE:

\documentclass[12pt]{scrartcl}

\usepackage[american]{babel}
\usepackage[utf8]{inputenx}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\usepackage{xcolor}
%\usepackage{pdfcomment}
%\pdfcommentsetup{author=me, color=yellow, open=true}

\title{Example in \LaTeX}
\author{rotton}

\begin{document}

\maketitle

\section{Example section}

Today is \today.
%\pdfcomment{This changes the date format}

\end{document}

Date appears as expected both in the title and text. When you comment in the first, first+second or all three lines related to pdfcomment and recompile, the date now appears as YYYY-MM-DD. A short test shows this to be independent of \documentclass and language settings. The pdfcomment manual states that one of the required packages is datetime2.

Is this behavior intended, or just an unwanted side-effect? If the latter, how to get the original date format back?

cgnieder
  • 66,645
winkmal
  • 845

2 Answers2

6

You should activate the localization of datetime2:

\documentclass[12pt]{scrartcl}

\usepackage[american]{babel}
\usepackage[utf8]{inputenx}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\usepackage{xcolor}
\usepackage{pdfcomment}
\DTMsetregional



\title{Example in \LaTeX}
\author{rotton}

\begin{document}


\maketitle

\section{Example section}

Today is \today.
%\pdfcomment{This changes the date format}

\end{document}
Ulrike Fischer
  • 327,261
  • Hm, both answers are correct and work. Which one is the "correct answer"? I will opt for this one since it requires less typing. Anyway, pdfcomment should not implicitly change the default date format, at least offer an option to disable this behavior. Would this qualify for a bug report/feature request? – winkmal Feb 07 '17 at 17:19
5

You can pass option useregional=numeric to package datetime2:

\documentclass[12pt]{scrartcl}

\usepackage[american]{babel}
\usepackage[utf8]{inputenx}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\usepackage{xcolor}
\PassOptionsToPackage{useregional=numeric}{datetime2}
\usepackage{pdfcomment}
\pdfcommentsetup{author=me, color=yellow, open=true}

\title{Example in \LaTeX}
\author{rotton}

\begin{document}

\maketitle

\section{Example section}

Today is \today.

\end{document}

useregional=numeric

See the datetime2 manual for more values of option useregional, e.g.,

\documentclass[12pt]{scrartcl}

\usepackage[american]{babel}
\usepackage[utf8]{inputenx}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\usepackage{xcolor}
\PassOptionsToPackage{useregional}{datetime2}
\usepackage{pdfcomment}
\pdfcommentsetup{author=me, color=yellow, open=true}

\title{Example in \LaTeX}
\author{rotton}

\begin{document}

\maketitle

\section{Example section}

Today is \today.

\end{document}

for

alphanum

Schweinebacke
  • 26,336
  • I just figured in order to keep default format "February 7, 2017" I need to use \PassOptionsToPackage{useregional}{datetime2} without the =numeric option. – winkmal Feb 07 '17 at 14:34