Goal
With datetime2
package I try to save the “\today
” date with \DTMdatesave
command, but it successively fail.
My tries
1. The dumb method
I began with the most evident way. Putting directly \today
as a second argument of \DTMdatesave
.
\DTMdatesave{today}{\today}
But, as expected it failed with the following error message:
\ifcsdef {@dtm@datestyle@iso}{\csuse {@dtm@datestyle@iso}}{\PackageError \ETC.
! Paragraph ended before \@dtm@parsedate was complete.
<to be read again>
\par
I think it failed probably because the \today{}
command didn’t print the ISO format date (YYYY-MM-DD).
2. Giving ISO formatted date
Then, I use \DTMsetdatestyle{iso}
command from datetime2
to convert \today
output into an ISO format:
\DTMsavedate{today}{\DTMsetdatestyle{iso}\today}
But it also give me the following error :
\ifcsdef {@dtm@datestyle@iso}{\csuse {@dtm@datestyle@iso}}{\PackageError \ETC.
! Paragraph ended before \@dtm@parsedate was complete.
<to be read again>
\par
l.10
3. Saving the command expansion
So, then, I thank I should give a saved output with \let
command.
Then, I did:
\newcommand\preparetoday{\DTMsetdatestyle{iso}\today{}}
\let\temptoday\preparetoday
\DTMsavedate{ShootDate}{\temptoday}
And it failed with same error message than the 1st method.
Question
How to store the “\today
” date in a datetime2
object?
Best Answer
Use the provided
\DTMsavenow
: