Date/time format strings convert a date value to text. They are used by tokens such as
<file-date>,
<exif-date>, and
<now>
(UTC, not your PC clock).
Patterns use fixed English rules (not your regional Windows date settings).
Standard letters use 24-hour time.
Prefer filename-safe custom patterns (for example
yyyy-MM-dd_HH-mm-ss). Characters such as : and / are not
valid in Windows file names.
A single letter selects a standard English pattern:
| Specifier | Name | Example |
|---|---|---|
d |
Short date | 11/29/2004 |
D |
Long date | Monday, 29 November 2004 |
t |
Short time | 10:36 |
T |
Long time | 10:36:22 |
f |
Full (short time) | Monday, 29 November 2004 10:36 |
F |
Full (long time) | Wednesday, 24 November 2004 14:21:34 |
g |
General (short time) | 11/24/2004 14:21 |
G |
General (long time) | 11/24/2004 14:21:34 |
M or m |
Month day | November 29 |
s |
Sortable (ISO 8601) | 2004-11-24T14:21:34 |
u |
Universal sortable | 2004-11-24 14:21:34Z |
Y or y |
Year month | 2004 November |
Examples below use 8 Nov 2004, 4:22:18 PM:
| Specifier | Description | Example |
|---|---|---|
d / dd |
Day of month (1-31); dd zero-pads |
8 / 08 |
ddd / dddd |
Abbreviated / full weekday name | Mon / Monday |
M / MM |
Month number; MM zero-pads |
11 / 11 |
MMM / MMMM |
Abbreviated / full month name | Nov / November |
y / yy / yyyy |
Year (1-2 digits, padded 2, or 4) | 4 / 04 / 2004 |
h / hh |
Hour 1-12 | 4 / 04 |
H / HH |
Hour 0-23 | 16 / 16 |
m / mm |
Minute 0-59 | 22 / 22 |
s / ss |
Second 0-59 | 18 / 18 |
t / tt |
A.M./P.M. designator (first char / full) | P / PM |
f…fffffff |
Fractional seconds (1-7 digits) | - |
z / zz / zzz |
Time-zone offset | +2 / +02 / +02:00 |
: / / |
Time / date separators (often unsafe in file names) | - |
'…' or "…" |
Quoted literal text | - |
\c |
Escape next character as literal | - |