Date & Time Format Directives
These directives are commonly used in tools likedate, logging systems, and programming languages to format timestamps.
Directives
| Directive | Represents | Example |
|---|---|---|
%Y | 4-digit year | 2026 |
%m | Month | 01-12 |
%d | Day of month | 01-31 |
%H | Hour (24-hour format) | 00-23 |
%M | Minute | 00-59 |
%S | Second | 00-59 |
Example Format
Example in Shell
Example for File Names
Common Patterns
| Pattern | Example | Use |
|---|---|---|
%Y-%m-%d | 2026-03-06 | Date only |
%Y%m%d | 20260306 | Compact date |
%Y-%m-%d %H:%M:%S | 2026-03-06 14:25:10 | Logs |
%Y%m%d-%H%M%S | 20260306-142510 | Filenames |
