,

Add date, month or year to your LaTeX document

Including the current date in your LaTeX document is quite straightforward. Simply put \today whereever you want the current timestamp (i.e. the date at the time of compiling the document), and you get the current date: \documentclass[english,a4paper,oneside,12pt]{article} \begin{document} Today’s date is \today \end{document} will produce Note that the date format will be adjusted to your…

Including the current date in your LaTeX document is quite straightforward. Simply put \today whereever you want the current timestamp (i.e. the date at the time of compiling the document), and you get the current date:

\documentclass[english,a4paper,oneside,12pt]{article}
\begin{document}
Today's date is \today
\end{document}

will produce

Note that the date format will be adjusted to your language (i.e., english as defined in documentclass).

How can you specify other formats? E.g. just the year or month? Usepackage datetime has the answer. First, specify a new dateformat in the preamble and use it in the main text. To get MONTH-YEAR dates, use

\documentclass[english,a4paper,oneside,12pt]{article} 
\usepackage{datetime}
\newdateformat{monthyeardate}{\monthname[\THEMONTH] \THEYEAR}
\begin{document} 
The current month is \monthyeardate\today 
\end{document}

Similarly, you can use \THEDAY, \THEMONTH, and \THEYEAR to customize your current date. For displaying the current time, you can simply use \currenttime

The current month is \monthyeardate\today (current time is \currenttime)

Tags:

Leave a Reply