date Command in Linux

Learn via video courses
Topics Covered

Build an AI-First Career, Master the Complete Skillset

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program
NSDC Certified

AI Forward Deployed Engineer Program

Full-stack engineering, production AI and client-facing consulting

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program

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.
Sharpen Your Fundamentals with Free Learning

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.

How Scaler Transformed Careers in Different Fields

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more

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

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

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.