Friday, November 11, 2011

The date utility-Part 2

The date utility also supports specifications of native language translations of month and weekday-names. The names used for a language are based on the locale specified by the environment variables LC_TIME and LANG in the environ command. The month and weekday names are taken from a file whose format is specified in strftime command. This file also defines country specific date and time formats such as %c, which defines the default format of date 


The field descriptors mentioned in the previous post are:
 a- abbreviated weekday name
 A- full weekday name
 b- abbreviated month name
 B- full month name
 c- country specific date and time format
 d- day of month 01 to 31
 D- date as %m/%d/%y
 e-  day of month 1 to 31(single digits are preceeded by a blank.
 h- abbreviated month name(alias for %b)
 H- hour 00 to 23
 I- hour 1 to 12
 j- day of year 001 to 366
 m- month of year 01 to 12
 M- minute 00 to 59
 n- insert a new line character
 p- string containing anti-meridiem(A.M.-before noon ) or post meridiem(PM- after noon)    
      indicator

 r- time as %I:%M:%S:%p
 R- time as%H:%M
 S- second 00 to 61 allow for leap seconds
  t- insert a tab character
 T- time as %H:%M:%S
 U- week number of year(Sunday as first day of the week)-0 to 53
w- day of week sunday = 0
W- week number of year(Monday as first day of the week) 00 to 53
x- Country specific date format
X- Country specific time format
y- Year within century 00 to 99
Y- year as ccyy(4 digits)
Z- time zone name

Examples:

1.date
   Lists the date and time of the server. Below is an example of the output.

   Fri Nov 11 16:47:32 MST 2011

2.date '+DATE: %m/%d/%y%nTIME:%H:%M:%S'
   Would list the time and date in the following format.
   
    DATE: 11/11/11
    TIME:  13:50:15

The following example would work only if you are the super user:
3.date -s "11/11/2011  01:48:00"

Sets the date to the date and time shown.


The next post would be about the who  command.

 

No comments:

Post a Comment