xref: /original-bsd/bin/date/date.1 (revision 95a66346)
1.\" Copyright (c) 1980, 1990 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\"     @(#)date.1	6.12 (Berkeley) 03/09/91
7.\"
8.Dd
9.Dt DATE 1
10.Os BSD 4.4
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
18.Op Fl r Ar seconds
19.Op Fl t Ar minutes_west
20.Op +format
21.Op [yy[mm[dd[hh]]]]mm[\&.ss]
22.Sh DESCRIPTION
23.Nm Date
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.
28.Pp
29The options are as follows:
30.Pp
31.Tw Ds
32.Tp Fl d
33Set the kernel's values for daylight savings time.
34If
35.Ar dst
36is non-zero, future calls
37to
38.Xr gettimeofday 2
39will return a non-zero
40.Ql tz_dsttime  .
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.
55.Tp Fl r
56Print out the date and time for
57.Ar seconds
58from the Epoch.
59.Tp Fl t
60Set the kernel's values for minutes west of GMT.
61.Ar Minutes_west
62specifies the number of minutes returned in
63.Ql tz_minuteswest
64by future calls to
65.Xr gettimeofday 2 .
66.Tp Fl u
67Display or set the date in UCT (universal) time.
68.Tp
69.Pp
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.
82The canonical representation for setting the date and time:
83.Dw Ds
84.Dp Ar yy
85Year in abbreviated form (.e.g 89 for 1989).
86.Dp Ar mm
87Numeric month.
88A number from 1 to 12.
89.Dp Ar dd
90Day, a number from 1 to 31.
91.Dp Ar hh
92Hour, a number from 0 to 23.
93.Dp Ar mm
94Minutes, a number from 0 to 59.
95.Dp Ar .ss
96Seconds, a number from 0 to 60.
97.Dp
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
106.Dl date ``+DATE: %m/%d/%y%nTIME: %H:%M:0n''
107.Pp
108will display:
109.Pp
110.Dl DATE: 11/21/87
111.Dl TIME: 13:36:16
112.Pp
113The command:
114.Pp
115.Dl date 8506131627
116.Pp
117sets the date to June 13 1985, 4:27 PM.
118.Pp
119The command:
120.Pp
121.Dl date 1432
122.Pp
123sets the time to 2:32 PM, without modifying the date.
124.Sh FILES
125.Dw /var/log/messages
126.Di L
127.Dp Pa /var/log/wtmp
128A record of date resets and time changes.
129.Dp Pa /var/log/messages
130A record of the user setting the time.
131.Sh SEE ALSO
132.Xr gettimeofday 2 ,
133.Xr strftime 3 ,
134.Xr utmp 5 ,
135.Xr timed 8
136.br
137.Em TSP:\ The\ Time\ Synchronization Protocol
138.Em for UNIX 4.3BSD ,
139R. Gusella
140and\ S.\ Zatti
141.Sh HISTORY
142.Nm Date
143appeared in Version 6 AT&T UNIX.
144.Sh DIAGNOSTICS
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.
147.Pp
148Occasionally, when
149.Xr timed
150synchronizes the time on many hosts, the setting of a new time value may
151require more than a few seconds.
152On these occasions,
153.Nm date
154prints: `Network time being set'.
155The message `Communication error with timed' occurs when the communication
156between
157.Nm date
158and
159.Xr timed
160fails.
161.Sh BUGS
162The system attempts to keep the date in a format closely compatible
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.
167