我可以将今天的日期更改为不同的格式:月份、年份、普通和数字。现在我还需要添加一个未来日期:从今天起 28 天。我该怎么做?
\documentclass[a4paper,12p]{article}
\usepackage{datetime}
\newdateformat{monthyeardate}{%
\monthname[\THEMONTH] \THEYEAR}
\newdateformat{normal}{%
\longdate \ordinaldate{\THEDAY} \monthname[\THEMONTH] \THEYEAR}
\newcommand\twodigits[1] {\ifnum#1<10 0#1\else #1\fi}
\newdateformat{quoteNo}{%
\THEYEAR--\twodigits{\THEMONTH}--\THEDAY }
\begin{document}
\normal \today \\
Quote No: \quoteNo \today --1 \\
Expiry: %28 days from now
\end{document}
答案1
使用advdate
。另请参阅:https://tex.stackexchange.com/a/188739/193767
\documentclass[a4paper,12p]{article}
\usepackage{datetime}
\newdateformat{monthyeardate}{%
\monthname[\THEMONTH] \THEYEAR}
\newdateformat{normal}{%
\longdate \ordinaldate{\THEDAY} \monthname[\THEMONTH] \THEYEAR}
\newcommand\twodigits[1] {\ifnum#1<10 0#1\else #1\fi}
\newdateformat{quoteNo}{%
\THEYEAR--\twodigits{\THEMONTH}--\THEDAY }
\usepackage{advdate}
\newcommand{\advanceday}[1][14]{%
\begingroup
\AdvanceDate[#1]%
\today%
\endgroup
}%
\begin{document}
\normal \today \\
Quote No: \quoteNo \today --1 \\
Expiry: \advanceday[28] %28 days from now
\end{document}