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