xref: /original-bsd/bin/date/date.1 (revision 00695d63)
1.\" Copyright (c) 1980, 1990, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" the Institute of Electrical and Electronics Engineers, Inc.
6.\"
7.\" %sccs.include.redist.roff%
8.\"
9.\"     @(#)date.1	8.3 (Berkeley) 04/28/95
10.\"
11.Dd
12.Dt DATE 1
13.Os
14.Sh NAME
15.Nm date
16.Nd display or set date and time
17.Sh SYNOPSIS
18.Nm date
19.Op Fl d Ar dst
20.Op Fl r Ar seconds
21.Op Fl t Ar minutes_west
22.Op Fl nu
23.Op Cm + Ns Ar format
24.Op [yy[mm[dd[hh]]]]mm[\&.ss]
25.Sh DESCRIPTION
26.Nm Date
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.
31.Pp
32The options are as follows:
33.Bl -tag -width Ds
34.It Fl d
35Set the kernel's value for daylight savings time.
36If
37.Ar dst
38is non-zero, future calls
39to
40.Xr gettimeofday 2
41will return a non-zero
42.Ql tz_dsttime  .
43.It Fl n
44The utility
45.Xr timed 8
46is used to synchronize the clocks on 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.
57.It Fl r
58Print out the date and time in
59.Ar seconds
60from the Epoch.
61.It Fl t
62Set the kernel's value for minutes west of
63.Tn GMT .
64.Ar Minutes_west
65specifies the number of minutes returned in
66.Ql tz_minuteswest
67by future calls to
68.Xr gettimeofday 2 .
69.It Fl u
70Display or set the date in
71.Tn UCT
72(universal) time.
73.El
74.Pp
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.
81A <newline> character is always output after the characters specified by
82the format string.
83The format string for the default display is:
84.Bd -literal -offset indent
85``%a %b %e %H:%M:%S %Z %Y''.
86.Ed
87.Pp
88If an operand does not have a leading plus sign, it is interpreted as
89a value for setting the system's notion of the current date and time.
90The canonical representation for setting the date and time is:
91.Pp
92.Bl -tag -width Ds -compact -offset indent
93.It Ar yy
94Year in abbreviated form (.e.g 89 for 1989).
95.It Ar mm
96Numeric month.
97A number from 1 to 12.
98.It Ar dd
99Day, a number from 1 to 31.
100.It Ar hh
101Hour, a number from 0 to 23.
102.It Ar mm
103Minutes, a number from 0 to 59.
104.It Ar .ss
105Seconds, a number from 0 to 61 (59 plus a a maximum of two leap seconds).
106.El
107.Pp
108Everything but the minutes is optional.
109.Pp
110Time changes for Daylight Saving and Standard time and leap seconds
111and years are handled automatically.
112.Sh EXAMPLES
113The command:
114.Bd -literal -offset indent
115date ``+DATE: %m/%d/%y%nTIME: %H:%M:%S''
116.Ed
117.Pp
118will display:
119.Bd -literal -offset indent
120DATE: 11/21/87
121TIME: 13:36:16
122.Ed
123.Pp
124The command:
125.Bd -literal -offset indent
126date 8506131627
127.Ed
128.Pp
129sets the date to
130.Dq Li "June 13, 1985, 4:27 PM" .
131.Pp
132The command:
133.Bd -literal -offset indent
134date 1432
135.Ed
136.Pp
137sets the time to
138.Li "2:32 PM" ,
139without modifying the date.
140.Sh ENVIRONMENTAL VARIABLES
141The following environment variables affect the execution of
142.Nm date :
143.Bl -tag -width TZ
144.It Ev TZ
145The timezone to use when displaying dates.
146See
147.Xr environ 7
148for more information.
149.El
150.Sh FILES
151.Bl -tag -width /var/log/messages -compact
152.It Pa /var/log/wtmp
153A record of date resets and time changes.
154.It Pa /var/log/messages
155A record of the user setting the time.
156.El
157.Sh SEE ALSO
158.Xr gettimeofday 2 ,
159.Xr strftime 3 ,
160.Xr utmp 5 ,
161.Xr timed 8
162.Rs
163.%T "TSP: The Time Synchronization Protocol for UNIX 4.3BSD"
164.%A R. Gusella
165.%A S. Zatti
166.Re
167.Sh DIAGNOSTICS
168Exit status is 0 on success, 1 if unable to set the date, and 2
169if able to set the local date, but unable to set it globally.
170.Pp
171Occasionally, when
172.Xr timed
173synchronizes the time on many hosts, the setting of a new time value may
174require more than a few seconds.
175On these occasions,
176.Nm date
177prints:
178.Ql Network time being set .
179The message
180.Ql Communication error with timed
181occurs when the communication
182between
183.Nm date
184and
185.Xr timed
186fails.
187.Sh BUGS
188The system attempts to keep the date in a format closely compatible
189with
190.Tn VMS .
191.Tn VMS ,
192however, uses local time (rather than
193.Tn GMT )
194and does not understand daylight-savings time.
195Thus, if you use both
196.Tn UNIX
197and
198.Tn VMS ,
199.Tn VMS
200will be running on
201.Tn GMT .
202.Sh STANDARDS
203The
204.Nm date
205command is expected to be compatible with
206.St -p1003.2 .
207