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