date
[option] [+
format]date
[options] [string]In the first form, print the current date and time, specifying an optional display format. In the second form, a privileged user can set the current date by supplying a numeric string. format can consist of literal text strings (blanks must be quoted) as well as field descriptors, whose values will appear as described below (the listing shows some logical groupings).
%n | Insert a newline. |
%t | Insert a tab. |
%m | Month of year (01-12). |
%d | Day of month (01-31). |
%y | Last two digits of year (00-99). |
%D | Date in |
%b | Abbreviated month name. |
%e | Day of month (1-31); pad single digits with a space. |
%Y | Four-digit year (e.g., 1996). |
%g | Week-based year within century (00-99). Solaris only. |
%G | Week-based year, including the century (0000-9999). Solaris only. |
%h | Same as |
%B | Full month name. |
%H | Hour in 24-hour format (00-23). |
%M | Minute (00-59). |
%S | Second (00-61); 61 permits leap seconds and double leap seconds. |
%R | Time in |
%T | Time in |
%k | Hour (24-hour clock, 0-23); single digits are preceded by a space. Solaris only. |
%l | Hour (12-hour clock, 1-12); single digits are preceded by a space. Solaris only. |
%I | Hour in 12-hour format (01-12). |
%p | String to indicate a.m. or p.m. (default is |
%r | Time in |
%a | Abbreviated weekday. |
%A | Full weekday. |
%w | Day of week (Sunday = 0). |
%u | Weekday as a decimal number (1-7), Sunday = 1. Solaris only. |
%U | Week number in year (00-53); start week on Sunday. |
%W | Week number in year (00-53); start week on Monday. |
%V | The ISO-8601 week number (01-53). In ISO-8601, weeks begin on a Monday, and week 1 of the year is the one that includes both January 4th and the first Thursday of the year. If the first Monday of January is the 2nd, 3rd, or 4th, the preceding days are part of the last week of the previous year. Solaris only. |
%j | Julian day of year (001-366). |
%Z | Time-zone name. |
%x | Country-specific date format. |
%X | Country-specific time format. |
%c | Country-specific date and time format (default is |
The actual formatting is done by the strftime(3) library routine. On Solaris, the country-specific formats depend on the setting of the LC_CTYPE, LC_TIME, LC_MESSAGES, and NLSPATH environment variables.
-a
s.
f(Privileged user only.) Gradually adjust the system clock until it drifts s seconds away from what it thinks is the "current" time. (This allows continuous micro-adjustment of the clock while the system is running.) f is the fraction of seconds by which time drifts. By default, the clock speeds up; precede s by a --
to slow down.
-u
Display or set the time using Greenwich Mean Time (UTC) .
A privileged user can set the date by supplying a numeric string. string consists of time, day, and year concatenated in one of three ways: time or [day]time or [day]time[year]. Note: don't type the brackets.
A two-digit hour and two-digit minute (HHMM); HH uses 24-hour format.
A two-digit month and two-digit day of month (mmdd); default is current day and month.
The year specified as either the full four digits or just the last two digits; default is current year.
Set the date to July 1 (0701
), 4 a.m. (0400
), 1999 (99
):
date 0701040099
The command:
date +"Hello%t Date is %D %n%t Time is %T"
produces a formatted date as follows:
Hello Date is 05/09/93 Time is 17:53:39