1.\" $OpenBSD: date.1,v 1.67 2016/09/12 17:28:47 jca Exp $ 2.\" $NetBSD: date.1,v 1.12 1996/03/12 04:32:37 phil Exp $ 3.\" 4.\" Copyright (c) 1980, 1990, 1993 5.\" The Regents of the University of California. All rights reserved. 6.\" 7.\" This code is derived from software contributed to Berkeley by 8.\" the Institute of Electrical and Electronics Engineers, Inc. 9.\" 10.\" Redistribution and use in source and binary forms, with or without 11.\" modification, are permitted provided that the following conditions 12.\" are met: 13.\" 1. Redistributions of source code must retain the above copyright 14.\" notice, this list of conditions and the following disclaimer. 15.\" 2. Redistributions in binary form must reproduce the above copyright 16.\" notice, this list of conditions and the following disclaimer in the 17.\" documentation and/or other materials provided with the distribution. 18.\" 3. Neither the name of the University nor the names of its contributors 19.\" may be used to endorse or promote products derived from this software 20.\" without specific prior written permission. 21.\" 22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32.\" SUCH DAMAGE. 33.\" 34.\" @(#)date.1 8.3 (Berkeley) 4/28/95 35.\" 36.Dd $Mdocdate: September 12 2016 $ 37.Dt DATE 1 38.Os 39.Sh NAME 40.Nm date 41.Nd display or set date and time 42.Sh SYNOPSIS 43.Nm date 44.Op Fl aju 45.Op Fl d Ar dst 46.Op Fl r Ar seconds 47.Op Fl t Ar minutes_west 48.Op Fl z Ar output_zone 49.Op Cm + Ns Ar format 50.Sm off 51.Oo Oo Oo Oo Oo Oo 52.Ar cc Oc 53.Ar yy Oc 54.Ar mm Oc 55.Ar dd Oc 56.Ar HH Oc 57.Ar MM 58.Op . Ar SS 59.Oc 60.Sm on 61.Sh DESCRIPTION 62When invoked without arguments, the 63.Nm 64utility displays the current date and time. 65Otherwise, depending on the options specified, 66.Nm 67will set the date and time or print it in a user-defined way. 68.Pp 69Changing the system date has some risks, as described in 70.Xr settimeofday 2 . 71Only the superuser may change the date. 72.Pp 73The options are as follows: 74.Bl -tag -width Ds 75.It Fl a 76Use the 77.Xr adjtime 2 78call to gradually skew the local time to the 79desired time rather than just hopping. 80.It Fl d Ar dst 81Set the system's value for Daylight Saving Time. 82If 83.Ar dst 84is non-zero, future calls 85to 86.Xr gettimeofday 2 87will return a non-zero value for 88.Fa tz_dsttime . 89.It Fl j 90Parse the provided date and time and display the result without changing 91the clock. 92.It Fl r Ar seconds 93Print out (in specified format) the date and time represented by 94.Ar seconds 95from the Epoch. 96.It Fl t Ar minutes_west 97Set the system's value for minutes west of GMT. 98.Ar minutes_west 99specifies the number of minutes returned in 100.Fa tz_minuteswest 101by future calls to 102.Xr gettimeofday 2 . 103.It Fl u 104Display or set the date in UTC (Coordinated Universal) time. 105.It Fl z Ar output_zone 106Just before printing the time, change to the specified timezone; 107see the description of 108.Ev TZ 109below. 110This can be used with 111.Fl j 112to easily convert time specifications from one zone to another. 113.El 114.Pp 115An operand with a leading plus sign 116.Pq Sq + 117signals a user-defined format 118string which specifies the format in which to display the date and time. 119The format string may contain any of the conversion specifications described 120in the 121.Xr strftime 3 122manual page, as well as any arbitrary text. 123A newline 124.Pq Ql \en 125character is always output after the characters specified by 126the format string. 127The format string for the default display is: 128.Bd -literal -offset indent 129%a %b %e %H:%M:%S %Z %Y 130.Ed 131.Pp 132If an operand does not have a leading plus sign, it is interpreted as 133a value for setting the system's notion of the current date and time. 134The canonical representation for setting the date and time is: 135.Pp 136.Bl -tag -width Ds -compact -offset indent 137.It Ar ccyy 138Year. 139If yy is specified, but cc is not, 140a value for yy between 69 and 99 results in a cc value of 19. 141Otherwise, a cc value of 20 is used. 142.It Ar mm 143Month: 144a number from 1 to 12. 145.It Ar dd 146Day: 147a number from 1 to 31. 148.It Ar HH 149Hour: 150a number from 0 to 23. 151.It Ar MM 152Minute: 153a number from 0 to 59. 154.It Ar SS 155Second: 156a number from 0 to 60 157(permitting a leap second), 158preceded by a period. 159.El 160.Pp 161Everything but the minute is optional. 162.Pp 163Time changes for Daylight Saving Time, standard time, leap seconds, 164and leap years are handled automatically. 165.Sh ENVIRONMENT 166.Bl -tag -width Ds 167.It Ev TZ 168The time zone to use when parsing or displaying dates. 169See 170.Xr environ 7 171for more information. 172If this variable is not set, the time zone is determined based on 173.Pa /etc/localtime , 174which the administrator adjusts using 175the 176.Fl l 177option of 178.Xr zic 8 . 179.El 180.Sh FILES 181.Bl -tag -width /var/log/messages -compact 182.It Pa /var/log/wtmp 183record of date resets and time changes 184.It Pa /var/log/messages 185record of the user setting the time 186.El 187.Sh EXIT STATUS 188.Ex -std 189.Sh EXAMPLES 190Display the date using the specified format string: 191.Bd -literal -offset indent 192$ date "+DATE: %Y-%m-%d%nTIME: %H:%M:%S" 193DATE: 1987-11-21 194TIME: 13:36:16 195.Ed 196.Pp 197Set the date to 198June 13, 1985, 4:27 PM: 199.Pp 200.Dl # date 198506131627 201.Pp 202Set the time to 2032:32 PM, 204without modifying the date: 205.Pp 206.Dl # date 1432 207.Sh SEE ALSO 208.Xr adjtime 2 , 209.Xr gettimeofday 2 , 210.Xr strftime 3 , 211.Xr utmp 5 , 212.Xr ntpd 8 , 213.Xr rdate 8 214.Sh STANDARDS 215The 216.Nm 217utility is compliant with the 218.St -p1003.1-2008 219specification. 220.Pp 221The flags 222.Op Fl adjrtz , 223as well as the conversion specifiers 224.Ql \&%F , 225.Ql \&%G , 226.Ql \&%g , 227.Ql \&%k , 228.Ql \&%l , 229.Ql \&%R , 230.Ql \&%s , 231.Ql \&%v , 232and 233.Ql \&%+ , 234are extensions to that specification. 235.Pp 236This implementation requires the traditional 237.Bx 238date format, 239[[[[[cc]yy]mm]dd]HH]MM[.SS], 240which differs from the 241X/Open System Interfaces option of the 242.St -p1003.1-2008 243specification. 244.Sh HISTORY 245A 246.Nm 247command appeared in 248.At v1 . 249