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.3 (Berkeley) 4/28/95 36.\" $FreeBSD$ 37.\" 38.Dd November 17, 1993 39.Dt DATE 1 40.Os 41.Sh NAME 42.Nm date 43.Nd display or set date and time 44.Sh SYNOPSIS 45.Nm date 46.Op Fl jnu 47.Op Fl d Ar dst 48.Op Fl r Ar seconds 49.Op Fl t Ar minutes_west 50.Op Fl v Ns Ar [+|-]val Ns Op ymwdHMS 51.Ar ... 52.Op Fl f Ar fmt Ar date | [[[[[cc]yy]mm]dd]HH]MM[\&.ss] 53.Op Cm + Ns Ar format 54.Sh DESCRIPTION 55.Nm Date 56displays the current date and time when invoked without arguments. 57Providing arguments will format the date and time in a user-defined 58way or set the date. 59Only the superuser may set the date. 60.Pp 61The options are as follows: 62.Bl -tag -width Ds 63.It Fl d 64Set the kernel's value for daylight savings time. 65If 66.Ar dst 67is non-zero, future calls 68to 69.Xr gettimeofday 2 70will return a non-zero 71.Ql tz_dsttime . 72.It Fl f 73Use 74.Ar fmt 75as the format string to parse the date provided rather than using 76the default 77.Ar [[[[[cc]yy]mm]dd]HH]MM[.ss] 78format. Parsing is done using 79.Xr strptime 3 . 80.It Fl j 81Do not try to set the date. This allows you to use the 82.Fl f 83flag in addition to the 84.Cm + 85option to convert one date format to another. 86.It Fl n 87The utility 88.Xr timed 8 89is used to synchronize the clocks on groups of machines. 90By default, if 91.Xr timed 92is running, 93.Nm 94will set the time on all of the machines in the local group. 95The 96.Fl n 97option stops 98.Nm 99from setting the time for other than the current machine. 100.It Fl r 101Print out the date and time in 102.Ar seconds 103from the Epoch. 104.It Fl t 105Set the kernel's value for minutes west of 106.Tn GMT . 107.Ar Minutes_west 108specifies the number of minutes returned in 109.Ql tz_minuteswest 110by future calls to 111.Xr gettimeofday 2 . 112.It Fl u 113Display or set the date in 114.Tn UCT 115(universal) time. 116.It Fl v 117Adjust the second, minute, hour, month day, week day, month or year according to 118.Ar val . 119If 120.Ar val 121is preceded with a plus or minus sign, the date is adjusted forwards 122or backwards according to the remaining string, otherwise the relevant 123part of the date is set. The date can be adjusted as many times as 124required using these flags. Flags are processed in the order given. 125.Pp 126Seconds are in the range 0-59, minutes are in the range 0-59, hours are 127in the range 1-12, month days are in the range 1-31, week days are in the 128range 0-6 (Sun-Sat), months are in the range 1-12 (Jan-Dec) and years are 129in the range 80-38 or 1980-2038. 130.Pp 131If 132.Ar val 133is numeric, one of either 134.Ar y , 135.Ar m , 136.Ar w , 137.Ar d , 138.Ar H , 139.Ar M 140or 141.Ar S 142must be used to specify which part of the date is to be adjusted. 143.Pp 144The week day or month may be specified using a name rather than a 145number. If a name is used with the plus (or minus) sign, the date 146will be put forwards (or backwards) to the next (previous) date that 147matches the given week day or month. This will not adjust the date 148if the given week day or month is the same as the current one. 149.Pp 150Refer to the examples below for further details. 151.El 152.Pp 153An operand with a leading plus (``+'') sign signals a user-defined format 154string which specifies the format in which to display the date and time. 155The format string may contain any of the conversion specifications described 156in the 157.Xr strftime 3 158manual page, as well as any arbitrary text. 159A <newline> character is always output after the characters specified by 160the format string. 161The format string for the default display is: 162.Bd -literal -offset indent 163``+%+'' 164.Ed 165.Pp 166If an operand does not have a leading plus sign, it is interpreted as 167a value for setting the system's notion of the current date and time. 168The canonical representation for setting the date and time is: 169.Pp 170.Bl -tag -width Ds -compact -offset indent 171.It Ar cc 172Century (either 19 or 20) prepended to the abbreviated year. 173.It Ar yy 174Year in abbreviated form (e.g. 89 for 1989, 06 for 2006). 175.It Ar mm 176Numeric month. 177A number from 1 to 12. 178.It Ar dd 179Day, a number from 1 to 31. 180.It Ar HH 181Hour, a number from 0 to 23. 182.It Ar MM 183Minutes, a number from 0 to 59. 184.It Ar .ss 185Seconds, a number from 0 to 61 (59 plus a maximum of two leap seconds). 186.El 187.Pp 188Everything but the minutes is optional. 189.Pp 190Time changes for Daylight Saving and Standard time and leap seconds 191and years are handled automatically. 192.Sh EXAMPLES 193The command: 194.Bd -literal -offset indent 195date "+DATE: %Y-%m-%d%nTIME: %H:%M:%S" 196.Ed 197.Pp 198will display: 199.Bd -literal -offset indent 200DATE: 1987-11-21 201TIME: 13:36:16 202.Ed 203.Pp 204The command: 205.Bd -literal -offset indent 206date -v1m -v+1y 207.Ed 208.Pp 209will display: 210.Bd -literal -offset indent 211Sun Jan 4 03:15:24 GMT 1998 212.Ed 213.Pp 214(where it is currently Mon Aug 4 04:15:24 BST 1997). 215.Pp 216The command: 217.Bd -literal -offset indent 218date -v1d -v3m -v0y -v-1d 219.Ed 220.Pp 221will display the last day of February in the year 2000: 222.Bd -literal -offset indent 223Tue Feb 29 03:18:00 GMT 2000 224.Ed 225.Pp 226The command: 227.Bd -literal -offset indent 228date -v1d -v+1m -v-1d -v-fri 229.Ed 230.Pp 231will display the last Friday of the month: 232.Bd -literal -offset indent 233Fri Aug 29 04:31:11 BST 1997 234.Ed 235.Pp 236(where it is currently Mon Aug 4 04:31:11 BST 1997). 237.Pp 238The command: 239.Bd -literal -offset indent 240date 8506131627 241.Ed 242.Pp 243sets the date to 244.Dq Li "June 13, 1985, 4:27 PM" . 245.Pp 246The command: 247.Bd -literal -offset indent 248date 1432 249.Ed 250.Pp 251sets the time to 252.Li "2:32 PM" , 253without modifying the date. 254.Sh ENVIRONMENT 255The execution of 256.Nm 257is affected by the following environment variables: 258.Bl -tag -width Ds 259.It Ev TZ 260The timezone to use when displaying dates. 261The normal format is a pathname relative to 262.Pa /usr/share/zoneinfo . 263For example, the command 264.Dq TZ=America/Los_Angeles date 265displays the current time in California. 266See 267.Xr environ 7 268for more information. 269.El 270.Sh FILES 271.Bl -tag -width /var/log/messages -compact 272.It Pa /var/log/wtmp 273a record of date resets and time changes 274.It Pa /var/log/messages 275a record of the user setting the time 276.El 277.Sh SEE ALSO 278.Xr gettimeofday 2 , 279.Xr strftime 3 , 280.Xr strptime 3 , 281.Xr utmp 5 , 282.Xr timed 8 283.Rs 284.%T "TSP: The Time Synchronization Protocol for UNIX 4.3BSD" 285.%A R. Gusella 286.%A S. Zatti 287.Re 288.Sh DIAGNOSTICS 289The 290.Nm 291utility exits 0 on success, 1 if unable to set the date, and 2 292if able to set the local date, but unable to set it globally. 293.Pp 294Occasionally, when 295.Xr timed 296synchronizes the time on many hosts, the setting of a new time value may 297require more than a few seconds. 298On these occasions, 299.Nm 300prints: 301.Ql Network time being set . 302The message 303.Ql Communication error with timed 304occurs when the communication 305between 306.Nm 307and 308.Xr timed 309fails. 310.Sh STANDARDS 311The 312.Nm 313command is expected to be compatible with 314.St -p1003.2 . 315.Sh HISTORY 316A 317.Nm 318command appeared in 319.At v1 . 320