date Command in Linux
Transform Your Career
Choose from our industry-leading programs designed for career success
Modern Software and AI Engineering Program
Master full-stack development with AI integration
+1000 moreModern Data Science and ML with specialisation in AI
Advanced data science techniques with AI specialization
+1000 moreAdvanced AIML with Specialisation in Agentic AI
Deep dive into AIML with focus on Agentic systems
+1000 moreDevOps, Cloud & AI Platform Engineering
Build and manage AI-powered cloud infrastructure
+1000 moreAI Engineering Advanced Certification by IIT-Roorkee
Premier AI engineering certification from IIT-Roorkee
Overview
The date command in Linux is a versatile utility used to display and manipulate the system's date and time. It can display the current date and time, set the system's date and time, or even format the date and time output to suit specific requirements.
Linux date Command Syntax
The syntax for the date command is as follows:
Where:
- OPTION: The options are flags that modify the behavior of the date command.
- FORMAT: The format specifies how the date and time should be displayed. It is preceded by a '+' sign.
date Command Options:
- -d, --date=STRING: Display time described by STRING, not 'now'.
- -f, --file=DATEFILE: Parse multiple date strings in DATEFILE.
- -R, --rfc-email: Output the date in RFC 5322 format, commonly used in email headers.
- -s, --set=STRING: Set the system time to the time described by STRING.
Example Usages
-
Display the current date and time:
Output:
Explanation: The default output displays the current date and time.
-
Display the date in a custom format:
Output:
Explanation: The output is formatted according to the given format string.
Scaler Placement Report and Statistics
Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.
Tips
-
Remember to precede the format string with a '+' sign.
-
Use the 'man date' command to see a full list of formatting options.
Advanced Use Cases of date Command in Linux
-
Calculate the date 7 days from now:
Output:
Explanation: The -d option allows us to display a future or past date based on the given STRING.
-
Get the Unix timestamp:
Output:
Explanation: The Unix timestamp is the number of seconds since January 1, 1970, 00:00:00 UTC.
-
Set the system time using the -s option:
Output:
Explanation: The system time is updated to the specified time. Note that you need root privileges to set the system time.
Turn Learning into Career Growth
Conclusion
-
The date command is a versatile utility for displaying and manipulating the system's date and time.
-
The output can be formatted according to specific requirements.
-
Advanced usages include calculating future or past dates and setting the system time.
-
Use the 'man date' command to explore additional formatting options and features.




