HowTo: UNIX Set Date and Time Command

h‮ptt‬s://www.lautturi.com
HowTo: UNIX Set Date and Time Command

To set the date and time on a Unix or Linux system, you can use the date command.

The date command allows you to set the date and time in a variety of formats, including the date and time, the date only, the time only, or the timezone.

To set the date and time, you can use the date command followed by the new date and time in the format YYYYMMDDhhmm.ss. For example, to set the date and time to January 1, 2021 at 12:00 PM (noon), you can use the following command:

date 202101011200.00

To set the date only, you can use the date command followed by the new date in the format YYYYMMDD. For example, to set the date to January 1, 2021, you can use the following command:

date 20210101

To set the time only, you can use the date command followed by the new time in the format hhmm.ss. For example, to set the time to 12:00 PM (noon), you can use the following command:

date 1200.00

To set the timezone, you can use the date command followed by the -u option and the timezone in the format hhmm. For example, to set the timezone to Eastern Standard Time (EST), you can use the following command:

date -u -0500

It is important to note that the date command requires superuser privileges to set the date and time. Therefore, you may need to use the sudo command to run the date command as the root user.

For more information about the date command and its options, you can consult the documentation for your specific Unix or Linux system.

Created Time:2017-10-29 22:08:45  Author:lautturi