About
Shop
LaTeX
Software
Books
Gallery
News
Contact
Blog
Settings
Account
Latest news 2024-12-13: Ebook sale (12th December 2024 – 1st January 2025): cybercrime fiction short stories Unsocial Media and Smile for the Camera free; crime fiction short story The Briefcase free; short story noir crime fiction I’ve Heard the Mermaid Sing free; crime fiction novel The Private Enemy US$1.99; illustrated children’s story The Foolish Hedgehog US$0.99.


4.2.1 Changing the Format of \today

In the previous exercise, we used the \today command to produce the current date. By default, this command displays the date in US format. To illustrate how to use packages, this section will look at how to use the datetime package to change the way that \today displays the date.

The datetime package has various options that can be used to change the format of \today. For example, by default the datetime package redefines \today to display the date in the form: Tuesday 25th September, 2012. The option short will produce an abbreviated form, (for example Tue 25th Sep, 2012) and the option nodayofweek won't display the day of the week (for example 25th Sep, 2012). For those who don't like the raised ordinal, there is the level option. These can be passed as a comma separated list in the optional argument to the \usepackage command. It is also possible to use a declaration instead. For example, to redefine \today to display the date in the form 25/09/2012, you can either do

\usepackage[ddmmyyyy]{datetime}

or

The datetime package also defines the command

\currenttime

which displays the current time, where again the format can be changed by the package options. So the option 12hr will cause \currenttime to display the date in 12 hour format (for example, 2:38pm) and the option 24hr will cause \currenttime to display the date in 24 hour format (for example, 14:38).

Exercise 3: Using the datetime Package

Edit your document from Exercise 2 so that it uses the datetime package. Experiment with the different package options, for example

\usepackage[short,nodayofweek,level,12hr]{datetime}

and add the current time

This document was created on: \today\␣at \currenttime.

You can download or view an example. For a full list datetime of package options, see the datetime documentation.


This book is also available as A4 PDF or 12.8cm x 9.6cm PDF or paperback (ISBN 978-1-909440-00-5).

© 2012 Dickimaw Books. "Dickimaw", "Dickimaw Books" and the Dickimaw parrot logo are trademarks. The Dickimaw parrot was painted by Magdalene Pritchett.

Terms of Use Privacy Policy Cookies Site Map FAQs