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