date Linux Commands
What is Linux date Command?
Explanation
date COMMAND:date command prints the date and time.
SYNTAX :
date[options][+format][date]
OPTIONS:
-a |
Slowly adjust the time by sss.fff seconds (fff represents fractions of a second).
This adjustment can be positive or negative.Only system admin/ super user can adjust the time. |
-sdate-string |
Sets the time and date to the value specfied in the datestring.
The datestr may contain the month names, timezones, 'am', 'pm', etc. |
-u |
Display (or set) the date in Greenwich Mean Time (GMT-universal time). |
Format:
%a |
Abbreviated weekday(Tue). |
%A |
Full weekday(Tuesday). |
%b |
Abbreviated month name(Jan). |
%B |
Full month name(January). |
%c |
Country-specific date and time format.. |
%D |
Date in the format %m/%d/%y. |
%j |
Julian day of year (001-366). |
%n |
Insert a new line. |
%p |
String to indicate a.m. or p.m. |
%T |
Time in the format %H:%M:%S. |
%t |
Tab space. |
%V |
Week number in year (01-52); start week on Monday. |
EXAMPLE:
- date command
date
The above command will print Wed Jul 23 10:52:34 IST 2008
- To use tab space:
date +"Date is %D %t Time is %T"
The above command will remove space and print as
Date is 07/23/08 Time is 10:52:34
- To know the week number of the year,
date -V
The above command will print 30
- To set the date,
date -s "10/08/2008 11:37:23"
The above command will print Wed Oct 08 11:37:23 IST 2008