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