Commit | Line | Data |
---|---|---|
b5dc1377 CL |
1 | .\" Copyright (c) 1980, 1990 The Regents of the University of California. |
2 | .\" All rights reserved. | |
3 | .\" | |
cf136d2c KB |
4 | .\" This code is derived from software contributed to Berkeley by |
5 | .\" the Institute of Electrical and Electronics Engineers, Inc. | |
6 | .\" | |
066c926d | 7 | .\" %sccs.include.redist.roff% |
b5dc1377 | 8 | .\" |
8f3fc90e | 9 | .\" @(#)date.1 6.16 (Berkeley) %G% |
b5dc1377 CL |
10 | .\" |
11 | .Dd | |
b5dc1377 | 12 | .Dt DATE 1 |
066c926d | 13 | .Os |
b5dc1377 CL |
14 | .Sh NAME |
15 | .Nm date | |
16 | .Nd display or set date and time | |
17 | .Sh SYNOPSIS | |
18 | .Nm date | |
b5dc1377 | 19 | .Op Fl d Ar dst |
39ab653e | 20 | .Op Fl r Ar seconds |
b5dc1377 | 21 | .Op Fl t Ar minutes_west |
066c926d CL |
22 | .Op Fl nu |
23 | .Op Cm + Ns Ar format | |
407e753d | 24 | .Op [yy[mm[dd[hh]]]]mm[\&.ss] |
b5dc1377 CL |
25 | .Sh DESCRIPTION |
26 | .Nm Date | |
407e753d KB |
27 | displays the current date and time when invoked without arguments. |
28 | Providing arguments will format the date and time in a user-defined | |
29 | way or set the date. | |
30 | Only the superuser may set the date. | |
5325ced3 | 31 | .Pp |
39ab653e | 32 | The options are as follows: |
066c926d CL |
33 | .Bl -tag -width Ds |
34 | .It Fl d | |
b5dc1377 CL |
35 | Set the kernel's values for daylight savings time. |
36 | If | |
37 | .Ar dst | |
38 | is non-zero, future calls | |
39 | to | |
5325ced3 CL |
40 | .Xr gettimeofday 2 |
41 | will return a non-zero | |
42 | .Ql tz_dsttime . | |
066c926d | 43 | .It Fl n |
407e753d KB |
44 | The utility |
45 | .Xr timed 8 | |
46 | is used to synchronize the clocks of groups of machines. | |
47 | By default, if | |
48 | .Xr timed | |
49 | is running, | |
50 | .Nm date | |
51 | will set the time on all of the machines in the local group. | |
52 | The | |
53 | .Fl n | |
54 | option stops | |
55 | .Nm date | |
56 | from setting the time for other than the current machine. | |
066c926d | 57 | .It Fl r |
39ab653e KB |
58 | Print out the date and time for |
59 | .Ar seconds | |
60 | from the Epoch. | |
066c926d CL |
61 | .It Fl t |
62 | Set the kernel's values for minutes west of | |
63 | .Tn GMT . | |
b5dc1377 | 64 | .Ar Minutes_west |
407e753d KB |
65 | specifies the number of minutes returned in |
66 | .Ql tz_minuteswest | |
67 | by future calls to | |
68 | .Xr gettimeofday 2 . | |
066c926d CL |
69 | .It Fl u |
70 | Display or set the date in | |
71 | .Tn UCT | |
72 | (universal) time. | |
73 | .El | |
b5dc1377 | 74 | .Pp |
407e753d KB |
75 | An operand with a leading plus (``+'') sign signals a user-defined format |
76 | string which specifies the format in which to display the date and time. | |
77 | The format string may contain any of the conversion specifications described | |
78 | in the | |
79 | .Xr strftime 3 | |
80 | manual page, as well as any arbitrary text. | |
81 | The format string for the default display is: | |
066c926d | 82 | .Bd -literal -offset indent |
4fb03741 | 83 | ``%a %b %e %H:%M:%S %Z n''. |
066c926d | 84 | .Ed |
407e753d KB |
85 | .Pp |
86 | If an operand does not have a leading plus sign, it is interpreted as | |
87 | a value for setting the system's notion of the current date and time. | |
b5dc1377 | 88 | The canonical representation for setting the date and time: |
066c926d CL |
89 | .Pp |
90 | .Bl -tag -width Ds -compact -offset indent | |
91 | .It Ar yy | |
b5dc1377 | 92 | Year in abbreviated form (.e.g 89 for 1989). |
066c926d | 93 | .It Ar mm |
b5dc1377 | 94 | Numeric month. |
407e753d | 95 | A number from 1 to 12. |
066c926d | 96 | .It Ar dd |
407e753d | 97 | Day, a number from 1 to 31. |
066c926d | 98 | .It Ar hh |
f9eecd6d | 99 | Hour, a number from 0 to 23. |
066c926d | 100 | .It Ar mm |
f9eecd6d | 101 | Minutes, a number from 0 to 59. |
066c926d CL |
102 | .It Ar .ss |
103 | Seconds, a number from 0 to 59. | |
104 | .El | |
407e753d KB |
105 | .Pp |
106 | Everything but the minutes are optional. | |
107 | .Pp | |
108 | Time changes for Daylight Saving and Standard time and leap seconds | |
109 | and years are handled automatically. | |
110 | .Sh EXAMPLES | |
111 | The command: | |
066c926d | 112 | .Bd -literal -offset indent |
4fb03741 | 113 | date ``+DATE: %m/%d/%y%nTIME: %H:%M:%n'' |
066c926d | 114 | .Ed |
407e753d KB |
115 | .Pp |
116 | will display: | |
066c926d CL |
117 | .Bd -literal -offset indent |
118 | DATE: 11/21/87 | |
119 | TIME: 13:36:16 | |
120 | .Ed | |
407e753d | 121 | .Pp |
b5dc1377 | 122 | The command: |
066c926d CL |
123 | .Bd -literal -offset indent |
124 | date 8506131627 | |
125 | .Ed | |
b5dc1377 | 126 | .Pp |
066c926d CL |
127 | sets the date to |
128 | .Dq Li "June 13 1985, 4:27 PM" . | |
b5dc1377 | 129 | .Pp |
407e753d | 130 | The command: |
066c926d CL |
131 | .Bd -literal -offset indent |
132 | date 1432 | |
133 | .Ed | |
b5dc1377 | 134 | .Pp |
066c926d CL |
135 | sets the time to |
136 | .Li "2:32 PM" , | |
137 | without modifying the date. | |
b5dc1377 | 138 | .Sh FILES |
066c926d CL |
139 | .Bl -tag -width /var/log/messages -compact |
140 | .It Pa /var/log/wtmp | |
b5dc1377 | 141 | A record of date resets and time changes. |
066c926d | 142 | .It Pa /var/log/messages |
407e753d | 143 | A record of the user setting the time. |
066c926d | 144 | .El |
b5dc1377 CL |
145 | .Sh SEE ALSO |
146 | .Xr gettimeofday 2 , | |
407e753d | 147 | .Xr strftime 3 , |
b5dc1377 | 148 | .Xr utmp 5 , |
5325ced3 | 149 | .Xr timed 8 |
066c926d CL |
150 | .Rs |
151 | .%T "TSP: The Time Synchronization Protocol for UNIX 4.3BSD" | |
152 | .%A R. Gusella | |
153 | .%A S. Zatti | |
154 | .Re | |
b5dc1377 | 155 | .Sh DIAGNOSTICS |
066c926d | 156 | Exit status is 0 on success, 1 if unable to set the date, and 2 |
407e753d | 157 | if able to set the local date but failing to set it globally. |
b5dc1377 CL |
158 | .Pp |
159 | Occasionally, when | |
5325ced3 | 160 | .Xr timed |
407e753d KB |
161 | synchronizes the time on many hosts, the setting of a new time value may |
162 | require more than a few seconds. | |
b5dc1377 CL |
163 | On these occasions, |
164 | .Nm date | |
066c926d CL |
165 | prints: |
166 | .Ql Network time being set . | |
167 | The message | |
168 | .Ql Communication error with timed | |
169 | occurs when the communication | |
b5dc1377 CL |
170 | between |
171 | .Nm date | |
172 | and | |
5325ced3 | 173 | .Xr timed |
b5dc1377 CL |
174 | fails. |
175 | .Sh BUGS | |
fd0821e6 | 176 | The system attempts to keep the date in a format closely compatible |
066c926d CL |
177 | with |
178 | .Tn VMS . | |
179 | .Tn VMS , | |
180 | however, uses local time (rather than | |
181 | .Tn GMT ) | |
182 | and does not understand | |
407e753d | 183 | daylight-saving time. |
066c926d CL |
184 | Thus, if you use both |
185 | .Tn UNIX | |
186 | and | |
187 | .Tn VMS , | |
188 | .Tn VMS | |
189 | will be running on | |
190 | .Tn GMT . | |
191 | .Sh HISTORY | |
8f3fc90e CL |
192 | The |
193 | .Nm date | |
066c926d | 194 | command is expected to be compatible with |
8f3fc90e | 195 | .St -p1003.2 . |