Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ date(1) — Reliant UNIX 5.44c4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cal(1)

sysadm(1M)

ctime(3C)

printf(3S)

environ(5)

date(1)                                                             date(1)

NAME
     date - print date and time or set system clock

SYNOPSIS
     date [-u] [+format]                                           Format 1

     date [-a [-]ssss.fff] [-u] [newdate]                         Format 2

DESCRIPTION
     date writes the current date and time on standard output (Format 1).
     The form in which date outputs dates and times depends on the value of
     the environment variable LCTIME or, if that is undefined or null, on
     the value of LANG. If both are undefined or null, or if the required
     database is not available, or if one of the NLS variables has an
     invalid value, date acts as if in a non-internationalized system,
     printing dates and times in American format.

     If you are the system administrator, you can also use date to set the
     system clock (Format 2); but you should not do this unless you are in
     single-user mode and all file systems have been unmounted. Changing
     the system clock may otherwise produce inconsistencies in the file
     systems.

   Mode of operation

     The system operates in coordinated universal time UTC (Universal Time
     Coordinated; synonymous with Greenwich Mean Time/GMT). date takes care
     of conversions to and from UTC to local time. If the environment vari-
     able TZ is defined, it is used to determine the timezone and to con-
     vert UTC to local time [see sh(1), "Standard shell variables"].

OPTIONS
   Format 1: Print date and time

     date [-u] [+format]

     No argument specified:
          date prints the current date and time in a format governed by the
          current locale.

     -u   Displays the current date and time in Greenwich Mean Time (GMT).

          If the -u option is set, the +format specification is ignored.

     +format
          The format argument defines the output format for date. If format
          contains blanks or tabs or other shell metacharacters which you
          do not want the shell to interpret, you should enclose format in
          single quotes: +'format'.






Page 1                       Reliant UNIX 5.44                Printed 11/98

date(1)                                                             date(1)

          format is essentially similar in format to the first argument of
          the printf function in C or awk [see awk(1), printf(1), and the
          C-function printf(3S)].

          The output of date can be formatted by means of field descriptors
          in the format argument. Field descriptors take the form of a per-
          centage sign followed by a letter and are replaced in the output
          by their values. All characters that are not part of a field
          descriptor are copied to the output unmodified. The output is
          always terminated with a newline character.

          The following overview lists all legal field descriptors. Although
          the field descriptors %h and %b are essentially identical, both
          descriptors have been retained for compatibility reasons.
          ___________________________________________________________________
         | %n  |  newline character                                         |
         |_____|____________________________________________________________|
         | %t  |  tab character                                             |
         |_____|____________________________________________________________|
         | %c  |  date and time in the default format of the current locale |
         |_____|____________________________________________________________|
         | %C  |  century (first two digits of the year, 00-99)             |
         |_____|____________________________________________________________|
         | %D  |  date in the format %m/%d/%y                               |
         |_____|____________________________________________________________|
         | %x  |  date in the format of the current locale                  |
         |_____|____________________________________________________________|
         | %y  |  year (last two digits of the year, 00-99)                 |
         |_____|____________________________________________________________|
         | %Y  |  year (all four digits of the year)                        |
         |_____|____________________________________________________________|
         | %m  |  month (01 to 12)                                          |
         |_____|____________________________________________________________|
         | %h  |  month (in letters, abbreviated) in the format of the      |
         |     |  current locale                                            |
         |_____|____________________________________________________________|
         | %b  |  identical to %h                                           |
         |_____|____________________________________________________________|
         | %B  |  month (in letters, in full) in the format of of the       |
         |     |  current locale                                            |
         |_____|____________________________________________________________|
         | %W  |  week number of the year (00 to 53, with Monday as the     |
         |     |  first day of the week). All days before the first Monday  |
         |     |  in January belong to week 0.                              |
         |_____|____________________________________________________________|
         | %V  |  week number of the year (01 to 53, with Monday as the     |
         |     |  first day of the week). The first week in January is      |
         |     |  counted as week 1 if it contains at least 4 days. Other-  |
         |     |  wise this week is counted as week 53 of the previous year |
         |     |  (in accordance with ISO 8601).                            |
         |_____|____________________________________________________________|



Page 2                       Reliant UNIX 5.44                Printed 11/98

date(1)                                                             date(1)

          ___________________________________________________________________
         | %U  |  week number of the year (00 to 53, with Sunday as the     |
         |     |  first day of the week). All days before the first Sunday  |
         |     |  in January belong to week 0.                              |
         |_____|____________________________________________________________|
         | %j  |  day of year (001 to 366)                                  |
         |_____|____________________________________________________________|
         | %d  |  day of month (01 to 31)                                   |
         |_____|____________________________________________________________|
         | %e  |  day of month (1 to 31, single-digit numbers preceded by a |
         |     |  blank)                                                    |
         |_____|____________________________________________________________|
         | %a  |  abbreviated weekday name in the format of the current     |
         |     |  locale                                                    |
         |_____|____________________________________________________________|
         | %A  |  full weekday name in the format of the current locale     |
         |_____|____________________________________________________________|
         | %w  |  day of week (0 to 6, Sunday = 0)                          |
         |_____|____________________________________________________________|
         | %u  |  day of week (1 to 7, Monday = 1)                          |
         |_____|____________________________________________________________|
         | %R  |  time in the format %H:%M                                  |
         |_____|____________________________________________________________|
         | %T  |  time in the format %H:%M:%S                               |
         |_____|____________________________________________________________|
         | %X  |  time in the format of the current locale                  |
         |_____|____________________________________________________________|
         | %r  |  time in a.m./p.m. notation, as %I:%M:%S %p                |
         |_____|____________________________________________________________|
         | %H  |  hour (00 to 23)                                           |
         |_____|____________________________________________________________|
         | %I  |  hour (01 to 12)                                           |
         |_____|____________________________________________________________|
         | %p  |  string containing ante-meridian or post-meridian indicator|
         |     |  (a.m./p.m. affix) in the format of the current locale.    |
         |_____|____________________________________________________________|
         | %M  |  minute (00 to 59)                                         |
         |_____|____________________________________________________________|
         | %S  |  second (00 to 61)                                         |
         |_____|____________________________________________________________|
         | %Z  |  timezone name, or no output if no timezone exists         |
         |     |  (governed by the value of the environment variable TZ, see|
         |     |  sh(1), "Standard shell variables").                       |
         |_____|____________________________________________________________|

          If an alternative representation is defined in your local envi-
          ronment (e.g. before and after Christ) you can call it using
          modified field descriptors. Modified field descriptors are in the
          form %Eletter or %Oletter. The modified field descriptors that
          can be used are listed in the overview below:




Page 3                       Reliant UNIX 5.44                Printed 11/98

date(1)                                                             date(1)

          If no alternative representation has been defined, all modified
          field descriptors output the value of the current unmodified
          field descriptors.
          ___________________________________________________________________
         | %Ec |  date and time in the alternative format                   |
         |_____|____________________________________________________________|
         | %EC |  name of the time period (e.g. "year") in the alternative  |
         |     |  representation                                            |
         |_____|____________________________________________________________|
         | %Ex |  date in the alternative format                            |
         |_____|____________________________________________________________|
         | %EX |  time in the alternative format                            |
         |_____|____________________________________________________________|
         | %Ey |  year in which the time period in the alternative represen-|
         |     |  tation begins                                             |
         |_____|____________________________________________________________|
         | %EY |  year in the alternative representation                    |
         |_____|____________________________________________________________|
         | %Od |  day of month in alternative numeric representation        |
         |_____|____________________________________________________________|
         | %Oe |  day of month in alternative numeric representation        |
         |_____|____________________________________________________________|
         | %OH |  hour (24-hour clock) in alternative numeric representation|
         |_____|____________________________________________________________|
         | %OI |  hour (12-hour clock) in alternative numeric representation|
         |_____|____________________________________________________________|
         | %Om |  month in alternative numeric representation               |
         |_____|____________________________________________________________|
         | %OM |  minutes in alternative numeric representation             |
         |_____|____________________________________________________________|
         | %OS |  seconds in alternative numeric representation             |
         |_____|____________________________________________________________|
         | %Ou |  weekday in the alternative format (Monday = 1)            |
         |_____|____________________________________________________________|
         | %OU |  week of the year in alternative numeric representation    |
         |     |  (same as for %U)                                          |
         |_____|____________________________________________________________|
         | %OV |  week of the year in alternative numeric representation    |
         |     |  (same as for %V)                                          |
         |_____|____________________________________________________________|
         | %Ow |  weekday in the alternative format (Sunday = 0)            |
         |_____|____________________________________________________________|
         | %OW |  week of the year in alternative numeric representation    |
         |     |  (same as for %W)                                          |
         |_____|____________________________________________________________|
         | %Oy |  year in the alternative format                            |
         |_____|____________________________________________________________|







Page 4                       Reliant UNIX 5.44                Printed 11/98

date(1)                                                             date(1)

   Format 2: Set system clock

     date [-a [-]ssss.fff] [-u] [newdate]

     This format is for the system administrator only.

     This format can be used to adjust the system clock or reset the date.

     -a [-]ssss.fff
          Adjusts the system clock time by ssss.fff seconds, where fff rep-
          resents fractions of a second. This adjustment can be positive or
          negative (-). The system's clock will be sped up or slowed down
          until it has changed by the specified amount (ssss may not exceed
          2146).

     -u   Sets the date and time in Greenwich Mean Time (see option -u
          under Format 1).

     newdate
          date sets the date and time of the system clock to the specified
          value. The following can be entered for [mmdd]HHMM or
          mmddHHMM[cc]yy:

       ____________________________________________________________________
      |     mm   |     dd   |     HH   |     MM   |     cc   |     yy     |
      |__________|__________|__________|__________|__________|____________|
      | month    | day      | hour     | minute   | century  | year (last |
      | (01 - 12)| (01 - 31)| (00 - 23)| (00 - 59)| minus 1  | 2 digits)  |
      |__________|__________|__________|__________|__________|____________|

          mmdd not specified:

          date assumes that the specified time HHMM refers to the current
          date.

          cc not specified:

          date assumes that the specified date mmddHHMMyy refers to the
          current century.

     The system clock should only be set in single-user mode when all file
     systems have been unmounted. Changing the system clock may otherwise
     lead to inconsistencies in the file systems.











Page 5                       Reliant UNIX 5.44                Printed 11/98

date(1)                                                             date(1)

ERROR MESSAGES
   Format 2

     date: no permission.

     You have tried to set the system clock as a normal user. This privi-
     lege is reserved for the system administrator.

     date: bad conversion.

     You have attempted to set the system clock but have called date with
     an incorrect format.

ENVIRONMENT VARIABLES
     TZ   If defined, the environment variable TZ contains information on
          timezones. date uses TZ to determine the timezone and to convert
          from UTC (Universal Time Coordinated) to local time and vice
          versa.

          The value of TZ consists of

          -  the standard timezone

          -  the offset from UTC in hours

          -  if relevant, the summer timezone with information for conver-
             sions from standard time to summer time (daylight saving time)
             and back.

          A detailed description of TZ is provided under sh(1) in the sec-
          tion "Standard shell variables".

LOCALE
     The LCMESSAGES environment variable governs the language in which
     message texts are displayed.

     The LCTIME environment variable governs the language and the format
     in which the date and time and the values of date and time constants
     are displayed.

     LCCTYPE governs character classes and character conversion (shift-
     ing).

     If LCMESSAGES, LCTIME or LCCTYPE is undefined or is defined as the
     null string, it defaults to the value of LANG. If LANG is likewise
     undefined or null, the system acts as if it were not international-
     ized.

     If any of the locale variables has an invalid value, the system acts
     as if none of the variables were set.




Page 6                       Reliant UNIX 5.44                Printed 11/98

date(1)                                                             date(1)

     The LCALL environment variable governs the entire locale. LCALL
     takes precedence over all the other environment variables which affect
     internationalization.

EXAMPLES
     Example 1: Printing date and time (LANG=EnUS.ASCII) [Format 1]

     If you call date without arguments at 7:43 hours MET on March 27,
     1997, and the system clock is set to the correct time, the following
     will be printed:

     Thu Mar 27 07:43:10 MET 1997

     The command:

     $ date '+DATE: %m/%d/%y%nTIME: %H:%M:%S'

     generates the following output:

     DATE: 03/27/97
     TIME: 07:59:51

     Example 2: Setting the system clock [Format 2]

     You are working under the system administrator login root and want to
     set the date and time to 16:30 on March 17, 1991. To do this, you must
     first switch to single-user mode and unmount all file systems. You
     then enter:

     # date 0317163091

     If you are calling date in the year 1991, there is no need to specify
     the year.

SEE ALSO
     cal(1), sysadm(1M), ctime(3C), printf(3S), LCTIME(4), environ(5).


















Page 7                       Reliant UNIX 5.44                Printed 11/98

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026