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 was wondering if there exists such a package, or an option, to write the date in the form 31.1.2012 for example, and then have LaTeX present it as "January 31, 2012". I am actually using LyX and there is an "environment" to put date, However, it puts it in the same manner I am writing it, and for ease of writing I would like to write only numbers.

share|improve this question
add comment

1 Answer

How about this?

\documentclass{article}
\usepackage{datetime}
\usdate
\def\mydate#1{\innermydate#1}
\def\innermydate#1.#2.#3{\formatdate{#1}{#2}{#3}}
\begin{document}
\mydate{31.1.2001}
\end{document}

The datetime package provides the commands \usdate and \formatdate (note that \usdate redefines \today). The macro \innermydate sets up the format in which to input dates. You could say \innermydate1.1.2001 but the syntax with braces is nicer in my opinion, so I borrowed a neat trick from this answer to facilitate it.

share|improve this answer
    
Thanks. It does work for LaTex, however in LyX it is a problem, since I can't use 'mydate' inside the document (I can write a 'TeX' line inside, but it doesn't output well). Is there a simple solution that will be convenient with LyX? –  Stewie Jan 31 '12 at 14:15
1  
I'm afraid I don't know. I can only answer the LaTeX part. I hate LyX! –  Ian Thompson Jan 31 '12 at 14:25
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.