Altering System Time and Date
In this article, we will show you how to alter the system time and date using the terminal in a Unix-like operating system, such as Linux. This is useful when you need to adjust the clock settings for your system, or if you want to change the date and time for specific purposes.
Step 1: Altering Time and Date
To alter both the time and date of the system, you can use the following command:
date -s "23 Dec 2010 20:00:00"
This command sets the system clock to December 23, 2010, at 8 PM. The -s
option tells the date
command to set the system time.
Step 2: Altering Only Time
To alter only the time and keep the date unchanged, you can use the following command:
date +%T -s "20:00:00"
This command sets the system clock to 8 PM without changing the date. The %T
format specifier tells date
to display the time in 24-hour format.
Step 3: Altering Only Date
To alter only the date and keep the time unchanged, you can use the following command:
date +%d%m%Y -s "23122010"
This command sets the system clock to December 23, 2010, without changing the time. The %d%m%Y
format specifier tells date
to display a string with day, month, and year in the format “ddmmmyy”.
Step 4: Verifying Changes
After running any of these commands, you can verify that the system clock has been altered by running:
date
This command displays the current date and time.
Conclusion:
In this article, we showed you how to alter the system time and date using the terminal in a Unix-like operating system. By using the date
command with different options and format specifiers, you can change only the time or date, or both. Remember to use the -s
option when setting the system clock to ensure that the changes take effect immediately.