How to Use Date to Display or Change the Date and Time

|

One of the most common Linux commands that most users will need to know is "date." Date is used to display or change the date and time. It is relatively easy to use and will probably be seen much more frequently than many other commands.

Use Date to Change or Display Date and Time

Step1 Use "--date=STRING" to display and print times that are different than the time right now. The STRING you specify can display dates and times previous ("ago"), in the future ("next") and can show months, time zones and other options.

Step2 Process many dates with the "-f" function. This is the DATEFILE tool and can save a lot of time while using standard input.

Step3 Use "-r" to see when date and time were last modified.

Step4 Set your system to Coordinated Universal Time with the "-u" function.

Learn Common Ways Date Is Used to Display and Change Date and Time

Step1 Print Wednesday's date on Friday by entering this command:
date--date="2 days ago"

Step2 Print the date that is two weeks and three days from now by entering this command:
date--date="two weeks three days"

Step3 Display and print the date of Saint Patrick's Day this year by inputting this function:
date--date='17 March +%'. A full list of these Format controls, like percent, can be found on Webtools (see Resources below).

Step4 Change your systems date and time using this command:
date--set='year-date time marker"
For example, if you set your system's date and time at 10:07 in the morning on July 3 of this year, it would look like this:
date--set="2007-7-3 10:07 AM"

Step5 Set a slow running clock ahead by five minutes using this format:
date--set='+5 minutes'

Step6 Remember that when creating an argument relevant to setting time, you must limit your input to numbers only. You will want to use a two-digit month (MM), two-digit day (DD), two-digit hour (HH) and two-digit minute (MM).

0 comment:

Post a Comment

 

©2009 computer technology World | Template Blue by TNB