]>
Commit | Line | Data |
---|---|---|
1 | .\" $NetBSD: date.1,v 1.22 1998/06/08 09:07:13 lukem Exp $ | |
2 | .\" | |
3 | .\" Copyright (c) 1980, 1990, 1993 | |
4 | .\" The Regents of the University of California. All rights reserved. | |
5 | .\" | |
6 | .\" This code is derived from software contributed to Berkeley by | |
7 | .\" the Institute of Electrical and Electronics Engineers, Inc. | |
8 | .\" | |
9 | .\" Redistribution and use in source and binary forms, with or without | |
10 | .\" modification, are permitted provided that the following conditions | |
11 | .\" are met: | |
12 | .\" 1. Redistributions of source code must retain the above copyright | |
13 | .\" notice, this list of conditions and the following disclaimer. | |
14 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
15 | .\" notice, this list of conditions and the following disclaimer in the | |
16 | .\" documentation and/or other materials provided with the distribution. | |
17 | .\" 3. All advertising materials mentioning features or use of this software | |
18 | .\" must display the following acknowledgement: | |
19 | .\" This product includes software developed by the University of | |
20 | .\" California, Berkeley and its contributors. | |
21 | .\" 4. Neither the name of the University nor the names of its contributors | |
22 | .\" may be used to endorse or promote products derived from this software | |
23 | .\" without specific prior written permission. | |
24 | .\" | |
25 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
26 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
27 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
28 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
29 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
30 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
31 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
32 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
33 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
34 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
35 | .\" SUCH DAMAGE. | |
36 | .\" | |
37 | .\" @(#)date.1 8.3 (Berkeley) 4/28/95 | |
38 | .\" | |
39 | .Dd September 22, 2004 | |
40 | .Dt DATE 1 | |
41 | .Os | |
42 | .Sh NAME | |
43 | .Nm date | |
44 | .Nd display or set date and time | |
45 | .Sh SYNOPSIS | |
46 | .Nm | |
47 | .Op Fl nu | |
48 | .Op Fl r Ar seconds | |
49 | .Op Cm + Ns Ar format | |
50 | .Nm | |
51 | .Op Fl u | |
52 | .Ar mmddhhmm[[cc]yy] | |
53 | .Sh DESCRIPTION | |
54 | .Nm | |
55 | displays the current date and time when invoked without arguments. | |
56 | Providing arguments will format the date and time in a user-defined | |
57 | way or set the date. Only the superuser may set the date. | |
58 | .Pp | |
59 | The options are as follows: | |
60 | .Bl -tag -width Ds | |
61 | .It Fl n | |
62 | The utility | |
63 | .Xr timed 8 | |
64 | is used to synchronize the clocks on groups of machines. | |
65 | By default, if | |
66 | timed | |
67 | is running, | |
68 | .Nm | |
69 | will set the time on all of the machines in the local group. | |
70 | The | |
71 | .Fl n | |
72 | option stops | |
73 | .Nm | |
74 | from setting the time for other than the current machine. | |
75 | .It Fl r | |
76 | Print out the date and time that is | |
77 | .Ar seconds | |
78 | from the Epoch. | |
79 | .It Fl u | |
80 | Display or set the date in | |
81 | .Tn UTC | |
82 | (universal) time. | |
83 | .El | |
84 | .Pp | |
85 | An operand with a leading plus (``+'') sign signals a user-defined format | |
86 | string which specifies the format in which to display the date and time. | |
87 | The format string may contain any of the conversion specifications described | |
88 | in the | |
89 | .Xr strftime 3 | |
90 | manual page, as well as any arbitrary text. | |
91 | A <newline> character is always output after the characters specified by | |
92 | the format string. | |
93 | The format string for the default display is: | |
94 | .Bd -literal -offset indent | |
95 | ``%a %b %e %H:%M:%S %Z %Y''. | |
96 | .Ed | |
97 | .Pp | |
98 | If an operand does not have a leading plus sign, it is interpreted as | |
99 | a value for setting the system's notion of the current date and time. | |
100 | The canonical representation for setting the date and time is: | |
101 | .Pp | |
102 | .Bl -tag -width Ds -compact -offset indent | |
103 | .It Ar cc | |
104 | The first two digits of the year (the century). | |
105 | .It Ar yy | |
106 | The second two digits of the year. If | |
107 | .Dq yy | |
108 | is specified, but | |
109 | .Dq cc | |
110 | is not, a value for | |
111 | .Dq yy | |
112 | between 69 and 99 results in a | |
113 | .Dq cc | |
114 | value of 19. Otherwise, a | |
115 | .Dq cc | |
116 | value of 20 is used. | |
117 | .It Ar mm | |
118 | The month of the year, from 1 to 12. | |
119 | .It Ar dd | |
120 | The day of the month, from 1 to 31. | |
121 | .It Ar hh | |
122 | The hour of the day, from 0 to 23. | |
123 | .It Ar mm | |
124 | The minute of the hour, from 0 to 59. | |
125 | .It Ar ss | |
126 | The second of the minute, from 0 to 61. | |
127 | .El | |
128 | .Pp | |
129 | Everything but the minutes is optional. | |
130 | .Pp | |
131 | Time changes for Daylight Saving and Standard time and leap seconds | |
132 | and years are handled automatically. | |
133 | .Sh ENVIRONMENT VARIABLES | |
134 | The following environment variables affect the execution of | |
135 | .Nm | |
136 | : | |
137 | .Bl -tag -width TZ | |
138 | .It Ev TZ | |
139 | The timezone to use when displaying dates. | |
140 | See | |
141 | .Xr environ 7 | |
142 | for more information. | |
143 | .El | |
144 | .Sh FILES | |
145 | .Bl -tag -width /var/log/messages -compact | |
146 | .It Pa /var/log/wtmp | |
147 | A record of date resets and time changes. | |
148 | .It Pa /var/log/messages | |
149 | A record of the user setting the time. | |
150 | .El | |
151 | .Sh EXAMPLES | |
152 | The command: | |
153 | .Bd -literal -offset indent | |
154 | date "+DATE: %m/%d/%y%nTIME: %H:%M:%S" | |
155 | .Ed | |
156 | .Pp | |
157 | will display: | |
158 | .Bd -literal -offset indent | |
159 | DATE: 11/21/87 | |
160 | TIME: 13:36:16 | |
161 | .Ed | |
162 | .Pp | |
163 | The command: | |
164 | .Bd -literal -offset indent | |
165 | date 061316271985 | |
166 | .Ed | |
167 | .Pp | |
168 | sets the date to | |
169 | .Dq Li "June 13, 1985, 4:27 PM" . | |
170 | .Pp | |
171 | The command: | |
172 | .Bd -literal -offset indent | |
173 | date 1432 | |
174 | .Ed | |
175 | .Pp | |
176 | sets the time to | |
177 | .Li "2:32 PM" , | |
178 | without modifying the date. | |
179 | .Sh DIAGNOSTICS | |
180 | The following exit values are returned: | |
181 | 0 The date was written successfully (either locally or globally) | |
182 | >0 An error occurred. | |
183 | .Pp | |
184 | Occasionally, when | |
185 | .Xr timed 8 | |
186 | synchronizes the time on many hosts, the setting of a new time value | |
187 | may require more than a few seconds. | |
188 | On these occasions, | |
189 | .Nm | |
190 | prints: | |
191 | .Ql Network time being set . | |
192 | The message | |
193 | .Ql Communication error with timed | |
194 | occurs when the communication | |
195 | between | |
196 | .Nm | |
197 | and timed fails. | |
198 | .Sh LEGACY SYNOPSIS | |
199 | .Nm | |
200 | .Op Fl nu | |
201 | .Op Fl r Ar seconds | |
202 | .Op Cm + Ns Ar format | |
203 | .Pp | |
204 | .Nm " " | |
205 | .Ar [[[[[cc]yy]mm]dd]hh]mm[\&.ss] | |
206 | .Sh LEGACY DIAGNOSTICS | |
207 | .Pp | |
208 | When invoked in legacy mode the following exit values are returned: | |
209 | 0 The date was written successfully | |
210 | 1 Unable to set the date | |
211 | 2 Able to set the local date, but unable to set it globally | |
212 | .Sh SEE ALSO | |
213 | .Xr gettimeofday 2 , | |
214 | .Xr strftime 3 , | |
215 | .Xr compat 5 , | |
216 | .Xr utmp 5 , | |
217 | .Xr timed 8 | |
218 | .Rs | |
219 | .%T "TSP: The Time Synchronization Protocol for UNIX 4.3BSD" | |
220 | .%A R. Gusella | |
221 | .%A S. Zatti | |
222 | .Re | |
223 | .Sh STANDARDS | |
224 | The | |
225 | .Nm | |
226 | utility supports the | |
227 | .St -susv3 . | |
228 | It is also expected to be compatible with | |
229 | .St -p1003.2 . |