don't log the date as changed before it actually happens
[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.\"
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
27displays the current date and time when invoked without arguments.
28Providing arguments will format the date and time in a user-defined
29way or set the date.
30Only the superuser may set the date.
5325ced3 31.Pp
39ab653e 32The options are as follows:
066c926d
CL
33.Bl -tag -width Ds
34.It Fl d
b5dc1377
CL
35Set the kernel's values for daylight savings time.
36If
37.Ar dst
38is non-zero, future calls
39to
5325ced3
CL
40.Xr gettimeofday 2
41will return a non-zero
42.Ql tz_dsttime .
066c926d 43.It Fl n
407e753d
KB
44The utility
45.Xr timed 8
46is used to synchronize the clocks of groups of machines.
47By default, if
48.Xr timed
49is running,
50.Nm date
51will set the time on all of the machines in the local group.
52The
53.Fl n
54option stops
55.Nm date
56from setting the time for other than the current machine.
066c926d 57.It Fl r
39ab653e
KB
58Print out the date and time for
59.Ar seconds
60from the Epoch.
066c926d
CL
61.It Fl t
62Set the kernel's values for minutes west of
63.Tn GMT .
b5dc1377 64.Ar Minutes_west
407e753d
KB
65specifies the number of minutes returned in
66.Ql tz_minuteswest
67by future calls to
68.Xr gettimeofday 2 .
066c926d
CL
69.It Fl u
70Display or set the date in
71.Tn UCT
72(universal) time.
73.El
b5dc1377 74.Pp
407e753d
KB
75An operand with a leading plus (``+'') sign signals a user-defined format
76string which specifies the format in which to display the date and time.
77The format string may contain any of the conversion specifications described
78in the
79.Xr strftime 3
80manual page, as well as any arbitrary text.
81The 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
86If an operand does not have a leading plus sign, it is interpreted as
87a value for setting the system's notion of the current date and time.
b5dc1377 88The 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 92Year in abbreviated form (.e.g 89 for 1989).
066c926d 93.It Ar mm
b5dc1377 94Numeric month.
407e753d 95A number from 1 to 12.
066c926d 96.It Ar dd
407e753d 97Day, a number from 1 to 31.
066c926d 98.It Ar hh
f9eecd6d 99Hour, a number from 0 to 23.
066c926d 100.It Ar mm
f9eecd6d 101Minutes, a number from 0 to 59.
066c926d
CL
102.It Ar .ss
103Seconds, a number from 0 to 59.
104.El
407e753d
KB
105.Pp
106Everything but the minutes are optional.
107.Pp
108Time changes for Daylight Saving and Standard time and leap seconds
109and years are handled automatically.
110.Sh EXAMPLES
111The command:
066c926d 112.Bd -literal -offset indent
4fb03741 113date ``+DATE: %m/%d/%y%nTIME: %H:%M:%n''
066c926d 114.Ed
407e753d
KB
115.Pp
116will display:
066c926d
CL
117.Bd -literal -offset indent
118DATE: 11/21/87
119TIME: 13:36:16
120.Ed
407e753d 121.Pp
b5dc1377 122The command:
066c926d
CL
123.Bd -literal -offset indent
124date 8506131627
125.Ed
b5dc1377 126.Pp
066c926d
CL
127sets the date to
128.Dq Li "June 13 1985, 4:27 PM" .
b5dc1377 129.Pp
407e753d 130The command:
066c926d
CL
131.Bd -literal -offset indent
132date 1432
133.Ed
b5dc1377 134.Pp
066c926d
CL
135sets the time to
136.Li "2:32 PM" ,
137without modifying the date.
b5dc1377 138.Sh FILES
066c926d
CL
139.Bl -tag -width /var/log/messages -compact
140.It Pa /var/log/wtmp
b5dc1377 141A record of date resets and time changes.
066c926d 142.It Pa /var/log/messages
407e753d 143A 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 156Exit status is 0 on success, 1 if unable to set the date, and 2
407e753d 157if able to set the local date but failing to set it globally.
b5dc1377
CL
158.Pp
159Occasionally, when
5325ced3 160.Xr timed
407e753d
KB
161synchronizes the time on many hosts, the setting of a new time value may
162require more than a few seconds.
b5dc1377
CL
163On these occasions,
164.Nm date
066c926d
CL
165prints:
166.Ql Network time being set .
167The message
168.Ql Communication error with timed
169occurs when the communication
b5dc1377
CL
170between
171.Nm date
172and
5325ced3 173.Xr timed
b5dc1377
CL
174fails.
175.Sh BUGS
fd0821e6 176The system attempts to keep the date in a format closely compatible
066c926d
CL
177with
178.Tn VMS .
179.Tn VMS ,
180however, uses local time (rather than
181.Tn GMT )
182and does not understand
407e753d 183daylight-saving time.
066c926d
CL
184Thus, if you use both
185.Tn UNIX
186and
187.Tn VMS ,
188.Tn VMS
189will be running on
190.Tn GMT .
191.Sh HISTORY
8f3fc90e
CL
192The
193.Nm date
066c926d 194command is expected to be compatible with
8f3fc90e 195.St -p1003.2 .