Linux Command date
Date usage 1:
FORMAT: date [OPTION]... [+ FORMAT]
FORMAT controls the output. Interpreted sequences are:
% A literal %
% A locale's abbreviated weekday name (e.g., Sun)
% A locale's full weekday name (e.g., Sunday)
% B locale's abbreviated month name (e.g., Jan)
% B locale's full month name (e.g., January)
% C locale's date and time (e.g., Thu Mar 3 23:05:25 2005)
% C century; like % Y, percentage t omit last two digits (e.g., 20)
% D day of month (e.g., 01)
% D date; same as % m/% d/% y
% E day of month, space padded; same as % _ d
% F full date; same as % Y-% m-% d
% G last two digits of year of ISO week number (see % G)
% G year of ISO week number (see % V); normally useful only with % V
% H same as % B
% H hour (00 .. 23)
% I hour (01 .. 12)
% J day of year (001. 366)
% K hour, space padded (0 .. 23); same as % _ H
% L hour, space padded (1 .. 12); same as % _ I
% M month (01 .. 12)
% M minute (00 .. 59)
% N a newline
% N nanoseconds (000000000 .. 999999999)
% P locale's equivalent of either AM or PM; blank if not known
% P like % p, but lower case
% R locale's 12-hour clock time (e.g., 11:11:04)
% R 24-hour and minute; same as % H: % M
% S seconds since 1970-01-01 00:00:00 UTC
% S second (00 .. 60)
% T a tab
% T time; same as % H: % M: % S
% U day of week (1 .. 7); 1 is Monday
% U week number of year, with Sunday as first day of week (00 .. 53)
% V iso week number, with Monday as first day of week (01 .. 53)
% W day of week (0 .. 6); 0 is Sunday
% W week number of year, with Monday as first day of week (00 .. 53)
% X locale's date representation (e.g., 12/31/99)
% X locale's time representation (e.g., 23:13:48)
% Y last two digits of year (00 .. 99)
% Y year
% Z + hhmm numeric time zone (e.g.,-0400)
%: Z + hh: mm numeric time zone (e.g)
%: Z + hh: mm: ss numeric time zone (e.g.,-04:00:00)
%: Z numeric time zone with: to necessary precision (e.g.,-04, + 05:30)
% Z alphabetic time zone abbreviation (e.g., EDT)
By default, date pads numeric fields with zeroes. The following optional flags may follow '% ':
-(Hyphen) do not pad the field
_ (Underscore) pad with spaces
0 (zero) pad with zeros
^ Use upper case if possible
# Use opposite case if possible
For example:
1. year, month, and day
$ date +%Y%m%d20150107
2. year, month, and day. Only the last two digits of the year are retained.
~$ date +%y%m%d150107
3. hours, minutes, And seconds
~$ date +%H%M%S233045
4. year, month, day, hour, minute, and second
~$ date +%Y%m%d%H%M%S20150107233145
To be continued ......