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.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 3. All advertising materials mentioning features or use of this software 16.\" must display the following acknowledgement: 17.\" This product includes software developed by the University of 18.\" California, Berkeley and its contributors. 19.\" 4. Neither the name of the University nor the names of its contributors 20.\" may be used to endorse or promote products derived from this software 21.\" without specific prior written permission. 22.\" 23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33.\" SUCH DAMAGE. 34.\" 35.\" @(#)date.1 8.2 (Berkeley) 11/17/93 36.\" 37.Dd November 17, 1993 38.Dt DATE 1 39.Os 40.Sh NAME 41.Nm date 42.Nd display or set date and time 43.Sh SYNOPSIS 44.Nm date 45.Op Fl d Ar dst 46.Op Fl r Ar seconds 47.Op Fl t Ar minutes_west 48.Op Fl nu 49.Op Cm + Ns Ar format 50.Op [yy[mm[dd[hh]]]]mm[\&.ss] 51.Sh DESCRIPTION 52.Nm Date 53displays the current date and time when invoked without arguments. 54Providing arguments will format the date and time in a user-defined 55way or set the date. 56Only the superuser may set the date. 57.Pp 58The options are as follows: 59.Bl -tag -width Ds 60.It Fl d 61Set the kernel's value for daylight savings time. 62If 63.Ar dst 64is non-zero, future calls 65to 66.Xr gettimeofday 2 67will return a non-zero 68.Ql tz_dsttime . 69.It Fl n 70The utility 71.Xr timed 8 72is used to synchronize the clocks on groups of machines. 73By default, if 74.Xr timed 75is running, 76.Nm date 77will set the time on all of the machines in the local group. 78The 79.Fl n 80option stops 81.Nm date 82from setting the time for other than the current machine. 83.It Fl r 84Print out the date and time in 85.Ar seconds 86from the Epoch. 87.It Fl t 88Set the kernel's value for minutes west of 89.Tn GMT . 90.Ar Minutes_west 91specifies the number of minutes returned in 92.Ql tz_minuteswest 93by future calls to 94.Xr gettimeofday 2 . 95.It Fl u 96Display or set the date in 97.Tn UCT 98(universal) time. 99.El 100.Pp 101An operand with a leading plus (``+'') sign signals a user-defined format 102string which specifies the format in which to display the date and time. 103The format string may contain any of the conversion specifications described 104in the 105.Xr strftime 3 106manual page, as well as any arbitrary text. 107The format string for the default display is: 108.Bd -literal -offset indent 109``%a %b %e %H:%M:%S %Z n''. 110.Ed 111.Pp 112If an operand does not have a leading plus sign, it is interpreted as 113a value for setting the system's notion of the current date and time. 114The canonical representation for setting the date and time is: 115.Pp 116.Bl -tag -width Ds -compact -offset indent 117.It Ar yy 118Year in abbreviated form (.e.g 89 for 1989). 119.It Ar mm 120Numeric month. 121A number from 1 to 12. 122.It Ar dd 123Day, a number from 1 to 31. 124.It Ar hh 125Hour, a number from 0 to 23. 126.It Ar mm 127Minutes, a number from 0 to 59. 128.It Ar .ss 129Seconds, a number from 0 to 61 (59 plus a a maximum of two leap seconds). 130.El 131.Pp 132Everything but the minutes is optional. 133.Pp 134Time changes for Daylight Saving and Standard time and leap seconds 135and years are handled automatically. 136.Sh EXAMPLES 137The command: 138.Bd -literal -offset indent 139date ``+DATE: %m/%d/%y%nTIME: %H:%M:0n'' 140.Ed 141.Pp 142will display: 143.Bd -literal -offset indent 144DATE: 11/21/87 145TIME: 13:36:16 146.Ed 147.Pp 148The command: 149.Bd -literal -offset indent 150date 8506131627 151.Ed 152.Pp 153sets the date to 154.Dq Li "June 13, 1985, 4:27 PM" . 155.Pp 156The command: 157.Bd -literal -offset indent 158date 1432 159.Ed 160.Pp 161sets the time to 162.Li "2:32 PM" , 163without modifying the date. 164.Sh ENVIRONMENTAL VARIABLES 165The following environment variables affect the execution of 166.Nm date : 167.Bl -tag -width TZ 168.It Ev TZ 169The timezone to use when displaying dates. 170See 171.Xr environ 7 172for more information. 173.El 174.Sh FILES 175.Bl -tag -width /var/log/messages -compact 176.It Pa /var/log/wtmp 177A record of date resets and time changes. 178.It Pa /var/log/messages 179A record of the user setting the time. 180.El 181.Sh SEE ALSO 182.Xr gettimeofday 2 , 183.Xr strftime 3 , 184.Xr utmp 5 , 185.Xr timed 8 186.Rs 187.%T "TSP: The Time Synchronization Protocol for UNIX 4.3BSD" 188.%A R. Gusella 189.%A S. Zatti 190.Re 191.Sh DIAGNOSTICS 192Exit status is 0 on success, 1 if unable to set the date, and 2 193if able to set the local date, but unable to set it globally. 194.Pp 195Occasionally, when 196.Xr timed 197synchronizes the time on many hosts, the setting of a new time value may 198require more than a few seconds. 199On these occasions, 200.Nm date 201prints: 202.Ql Network time being set . 203The message 204.Ql Communication error with timed 205occurs when the communication 206between 207.Nm date 208and 209.Xr timed 210fails. 211.Sh BUGS 212The system attempts to keep the date in a format closely compatible 213with 214.Tn VMS . 215.Tn VMS , 216however, uses local time (rather than 217.Tn GMT ) 218and does not understand daylight-savings time. 219Thus, if you use both 220.Tn UNIX 221and 222.Tn VMS , 223.Tn VMS 224will be running on 225.Tn GMT . 226.Sh STANDARDS 227The 228.Nm date 229command is expected to be compatible with 230.St -p1003.2 . 231