The following codes are used to pass formatted date and time strings to external programs. They are also quite often used to pass date strings to the internal commands - for example, to create a folder named after the current date, you might use a command like CreateFolder {date|yyyyMMdd}.
Code |
Description |
---|---|
{date|<format>} |
Current date (local time). |
{dateu|<format>} |
Current date (UTC). |
{time|<format>} |
Current time (local time). |
{timeu|<format>} |
Current time (UTC). |
The <format> value is a string consisting of various tokens that are used to format the date and time strings. If no format is specified, your default system date and time format is used.
As an example, {date|YYYY-MM-dd} would format the date
like 2011-09-22, and {time|hhmmss} would format the
time like 084450.
The date codes use the following tokens - note that these tokens are case sensitive! The ISO week and ISO year tokens refer to the ISO week date system.
Date token |
Description |
---|---|
d |
Day of month as a number, with no leading zero for single-digit days. |
dd |
Day of month as a number, with a leading zero for single-digit days. |
ddd |
Day of week as a three-letter abbreviation (e.g. Wed). |
dddd |
Day of week as its full name (e.g. Wednesday). |
w |
ISO week number, no leading zero. |
ww |
ISO week number, leading zero. |
W |
Simple week number, no leading zero. |
WW |
Simple week number, leading zero. |
M |
Month as a number, no leading zero. |
MM |
Month as a number, leading zero. |
MMM |
Month as a three-letter abbreviation (e.g. Jan). |
MMMM |
Month as its full name (e.g. January). |
y |
Year as last two digits, but with no leading zero for years less than 10 (e.g. 2009 -> 9). |
yy |
Year as last two digits, with a leading zero (e.g. 2009 -> 09). |
yyyy |
Year as a four digit number. |
Y |
ISO year as last two digits, no leading zero. |
YY |
ISO year as last two digits, leading zero. |
YYYY |
ISO year as four digit number. |
gg |
Period/era string - ignored if the date to be formatted does not have an associated era. |
The time codes use the following tokens - these are also case sensitive.
Time token |
Description |
---|---|
h |
Hours with no leading zero for single-digit hours, 12 hour clock. |
hh |
Hours with leading zero for single-digit hours, 12 hour clock. |
H |
Hours with no leading zero, 24 hour clock. |
HH |
Hours with leading zero, 24 hour clock. |
m |
Minutes with no leading zero. |
mm |
Minutes with leading zero. |
s |
Seconds with no leading zero. |
ss |
Seconds with leading zero. |
t |
One-character AM/PM string (e.g. A or P). |
tt |
Multiple-character AM/PM string. |