Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a document in which I have some date and time formats defined using the package datetime. Specifically, I have something such as the following in the preamble:

    \newtimeformat{RFStimeA}{\twodigit{\THEHOUR}\twodigit{\THEMINUTE}\twodigit{\THESECOND}}
    \newdateformat{RFSdateA}{\THEDAY~\monthname[\THEMONTH] \THEYEAR}
    \newdateformat{RFSdateB}{\THEYEAR-\twodigit{\THEMONTH}-\twodigit{\THEDAY} }
    \newdateformat{RFSdateTimeA}{\THEYEAR-\twodigit{\THEMONTH}-\twodigit{\THEDAY}T\RFStimeA}

These defined formats can be used in the document in a manner such as the following:

This document is for the date \RFSdateB\today.

This setup works fine if the date to be typeset in the document is the current date. What I need to be able to do is switch between current dates and specified dates in a manner such as the following (in the preamble):

% Set the date.
    % Define the date.
        \date{2013-09-08}
    % Use today's date.
        %\date{\today}

What code should I use in the document (in place of something such as \RFSdateB\today) in order to be able to cope with such a 'switch' in the preamble? How should I specify the date in the preamble? Thanks for any ideas you may have!

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

You can set a new date using \newdate{<datename>}{<year>}{<month>}{<day>} and retrieve it with \displaydate{<datename>}:

enter image description here

\documentclass{article}
\usepackage{datetime}% http://ctan.org/pkg/datetime

\newtimeformat{RFStimeA}{\twodigit{\THEHOUR}\twodigit{\THEMINUTE}\twodigit{\THESECOND}}
\newdateformat{RFSdateA}{\THEDAY~\monthname[\THEMONTH] \THEYEAR}
\newdateformat{RFSdateB}{\THEYEAR-\twodigit{\THEMONTH}-\twodigit{\THEDAY} }
\newdateformat{RFSdateTimeA}{\THEYEAR-\twodigit{\THEMONTH}-\twodigit{\THEDAY}T\RFStimeA}

\begin{document}
RFSdateA: \RFSdateA\today \par
RFSdateB: \RFSdateB\today \par
\newdate{mydate}{8}{9}{2013}%
RFSdateA: \RFSdateA\displaydate{mydate} \par
RFSdateB: \RFSdateB\displaydate{mydate}
\end{document}
share|improve this answer
    
That works perfectly! Thank you very much for your assistance! –  d3pd Oct 14 '13 at 10:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.