How to Use “date” Command in Linux [8 Practical Examples] | LinuxSimply

preview_player
Показать описание

The Linux “date” command is one of the most used commands. Let’s unveil the time-travelling capabilities of the 'date' command in Linux with our comprehensive guide featuring 8 practical examples. From displaying the current date and time to manipulating time zones and file timestamps, explore the diverse functionalities of this essential command.

The 'date' command in Linux is used to display or set the system date and time. It provides various formatting options to customize the output according to user preferences. Additionally, 'date' can be used in shell scripts or command pipelines for tasks like timestamping files or generating dynamic content.

💡 Key Topics Covered:
1. Discover the fundamental, syntax, options and formats of the 'date' command in Linux.
2. Learn how to display the current date and time along with the abbreviated day of the week and time zone.
3. Master the art of converting a given string into a date and time.
4. Setting the system date and time and viewing specific time zones using the 'date' command.
6. Discover how to get the last modification time and extract the last modification date and time from a file using the 'date' command.
8. Learn the art of specifying date formats using the 'date' command in Linux.

Unravel the mysteries of time manipulation with the 'date' command and elevate your Linux command-line proficiency. For detailed commands and additional insights, refer to the comprehensive article and commands provided below. Subscribe for more Linux insights and embark on a journey through the realms of time with the 'date' command!

Content Index
0:00 Introduction
0:19 What is the “date” Command?
1:26 Example 1: Display the Current Date and Time with the Abbreviated Day of the Week and Time Zone
1:52 Example 2: Display the Current Date and Time in UTC Time Zone
2:16 Example 3: Converting a Given String into a Date and Time
4:09 Example 4: Setting the System Date and Time
5:15 Example 5: Viewing Specific Time Zone
5:55 Example 6: Getting the Last Modification Time of a File
6:24 Example 7: Extracting Date and Time from a Date File
7:07 Example 8: Specifying Date Formats

Instructor Details
Sharmin Ara Karim

Editor Details
Reshma Raj

Article Link
The “date” Command in Linux [8+ Practical Examples]

Commands Used
-----------------------------------------------
What is the “date” Command?
man date.

Example 1: Display the Current Date and Time with the Abbreviated Day of the Week and Time Zone
Date

Example 2: Display the Current Date and Time in UTC Time Zone
date -u

Example 3: Converting a Given String into a Date and Time
1. date --date="today" or date -d today
2. date --date="2 years ago" or date -d="2 years ago"
3. date -d="tomorrow" or date –date="tomorrow"

Example 4: Setting the System Date and Time
sudo date --set="Nov 13 03:23:34 PM CST 2016"

Example 5: Viewing Specific Time Zone
TZ='USA/NY' date

Example 6: Getting the Last Modification Time of a File

Example 7: Extracting Date and Time from a Date File

Example 8: Specifying Date Formats
date "+%A %B %d %T %y"
-------------------------------------------------------------------------

Follow Us

#linux
#linuxsimply
#linuxtutorial
#date
#command
#ubuntu
Рекомендации по теме
welcome to shbcf.ru