date
Quick Reference
Command Name:
date
Category:
system
Platform:
linux
Basic Usage:
Common Use Cases
- 1
Time synchronization
Display or set the current system date and time
- 2
Formatting timestamps
Convert between different date and time formats
- 3
Script timestamping
Add timestamps to logs or output in shell scripts
- 4
Date calculations
Perform date arithmetic for scheduling and planning
Syntax
date [OPTION]... [+FORMAT] date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
Options
Option | Description |
---|---|
-d, --date=STRING | Display time described by STRING, not 'now' |
-f, --file=DATEFILE | Like --date; once for each line of DATEFILE |
-I[FMT], --iso-8601[=FMT] | Output date/time in ISO 8601 format. FMT='date' for date only, 'hours', 'minutes', 'seconds', or 'ns' |
-R, --rfc-email | Output date and time in RFC 5322 format (e.g., Thu, 21 Dec 2000 16:01:07 +0200) |
-r, --reference=FILE | Display the last modification time of FILE |
-s, --set=STRING | Set time described by STRING |
-u, --utc, --universal | Print or set Coordinated Universal Time (UTC) |
--help | Display help information and exit |
--version | Output version information and exit |
Examples
How to Use These Examples
The examples below show common ways to use the date
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
Basic Examples:
# Display current date and time date
Advanced Examples:
# Set system date and time (requires root privileges) sudo date -s "2023-06-15 14:30:00"