date Command Purpose Displays or sets the date or time. Syntax To Set the Date and Time as Root User /usr/bin/date [ -n ] [ -u ] [ Date ] [ +FieldDescriptor ... ] To Display the Date and Time /usr/bin/date [ -u ] [ +FieldDescriptor ... ] Description Warning: Do not change the date when the system is running with more than one user. The date command writes the current date and time to standard output if called with no flags or with a flag list that begins with a + (plus sign). Otherwise, it sets the current date. Only a root user can change the date and time. The date command prints out the usage message on any unrecognized flags or input. The following formats can be used when setting the date with the Date parameter: * mmddHHMM[.SSyy] (default) * yymmddHHMM[.SS] * ddmmHHMMyy[.SS] The variables to the Date parameter are defined as follows: mm Specifies the month number. dd Specifies the number of the day in the month. HH Specifies the hour in the day (using a 24-hour clock). MM Specifies the minute number. SS Specifies the number of seconds. yy Specifies the last two numbers of the year. Note: If the yymmdd format is specified, the value of the yy var- iable must be 88 to 99. The current month, day, hour, and year are default values. The system operates in Coordinated Universal Time (CUT). If you follow the date command with a + (plus sign) and a field descriptor, you can control the output of the command. You must precede each field descriptor with a % (percent sign). The sys- tem replaces the field descriptor with the specified value. Enter a literal % as %%(two percent signs). The date command copies any other characters to the output without change. The date command always ends the string with a new-line character. Flags -n Does not set the time globally on all machines in a local area network that have their clocks synchronized. -u Displays and/or sets the time in Coordinated Universal Time (CUT). Field Descriptors %a Displays the locale's abbreviated weekday name. %A Displays the locale's full weekday name. %b Displays the locale's abbreviated month name. %B Displays the locale's full month name. %c Displays the locale's appropriate date and time representation (default). %d Displays the day of the month as a decimal number (01-31). %D Displays the date in the format equivalent to %m/%d/%y. %e Displays the day of the month as a decimal number (1-31 in a two-digit field leading fill). %h Displays the locale's abbreviated month name (a synonym for %b). %H Displays the hour (24-hour clock) as a decimal number (00-23). %I Displays the hour (12-hour clock) as a decimal number (01-12). %j Displays the day of year as a decimal number (001-366). %m Displays the month of year as a decimal number (01-12). %M Displays the minutes as a decimal number (00-59). %n Inserts a character. %p Displays the locale's equivalent of either AM or PM. %r Displays 12-hour clock time (01-12) using the AM-PM notation; in the POSIX locale, this is equivalent to %I:%M:%S %p. %S Displays the seconds as a decimal number (00-59). %t Inserts a character. %T Displays the 24-hour clock (00-23) in the format equivalent to %H:%M:%S. %U Displays the week number of the year as a decimal number (00- 53) counting Sunday as the first day of the week. %w Displays the weekday as a decimal number (Sunday = 0). %W Displays the week number of the year as a decimal number (00- 53) counting Monday as the first day of the week. %x Displays the locale's appropriate date representation. %X Displays the locale's appropriate time representation. %y Displays the last two numbers of the year (00-99). %Y Displays the year with century as a decimal number. %Z Displays the time-zone name, or no character if no time zone is determinable. %% Displays a % (percent sign) character. Exit Status This command returns the following exit values: 0 The date was written successfully. >0 An error occurred. Examples 1. To display current date and time, enter: date 2. To set the date and time, enter: date 02171425.4590 This sets the date and time to Sat Feb 17 14:25:45 CST 1990. Note: You must have root authority to change the date and time. 3. To display the date and time in a specified format, enter: date +"%r %a %d %h %y (Julian Date: %j)" This displays the date shown in Example 2 as: 02:25:03 PM Fri 17 Feb 90 (Julian Date: 048) Environment Variables The following environment variables affect the execution of date. LANG Determines the locale to use when both LC_ALL and the corresponding environment variable (beginning with LC_) do not specify a locale. LC_ALL Determines the locale to be used to override any values for locale categories specified by the setting of LANG or any en- vironment variable beginning with LC_. LC_CTYPE Determines the locale for the interpretation of se- quences of bytes of text data as characters (for example, single versus multibyte character in an argument). LC_MESSAGES Determines the language in which messages should be written. LC_TIME Determines the contents of date and time strings written by date. TZ Specifies the time zone in which the time and date are writ- ten, unless the -u option is specified. If the TZ variable is not set and the -u flag is not specified, an unspecified system default time zone is used. Implementation Specifics This command is part of Base Operating System (BOS) Runtime. Related Information Understanding Locale in AIX Version 3.2 System Management Guide: Operating System and Devices discusses locale values. The localtime subroutine, strftime subroutine, time subrou- tine. The environment file.