1*748ccd45Sderaadt.\" $OpenBSD: date.1,v 1.72 2021/04/29 00:47:53 deraadt Exp $ 2c4cafe02Sniklas.\" $NetBSD: date.1,v 1.12 1996/03/12 04:32:37 phil Exp $ 3df930be7Sderaadt.\" 4df930be7Sderaadt.\" Copyright (c) 1980, 1990, 1993 5df930be7Sderaadt.\" The Regents of the University of California. All rights reserved. 6df930be7Sderaadt.\" 7df930be7Sderaadt.\" This code is derived from software contributed to Berkeley by 8df930be7Sderaadt.\" the Institute of Electrical and Electronics Engineers, Inc. 9df930be7Sderaadt.\" 10df930be7Sderaadt.\" Redistribution and use in source and binary forms, with or without 11df930be7Sderaadt.\" modification, are permitted provided that the following conditions 12df930be7Sderaadt.\" are met: 13df930be7Sderaadt.\" 1. Redistributions of source code must retain the above copyright 14df930be7Sderaadt.\" notice, this list of conditions and the following disclaimer. 15df930be7Sderaadt.\" 2. Redistributions in binary form must reproduce the above copyright 16df930be7Sderaadt.\" notice, this list of conditions and the following disclaimer in the 17df930be7Sderaadt.\" documentation and/or other materials provided with the distribution. 1829295d1cSmillert.\" 3. Neither the name of the University nor the names of its contributors 19df930be7Sderaadt.\" may be used to endorse or promote products derived from this software 20df930be7Sderaadt.\" without specific prior written permission. 21df930be7Sderaadt.\" 22df930be7Sderaadt.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23df930be7Sderaadt.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24df930be7Sderaadt.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25df930be7Sderaadt.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26df930be7Sderaadt.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27df930be7Sderaadt.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28df930be7Sderaadt.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29df930be7Sderaadt.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30df930be7Sderaadt.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31df930be7Sderaadt.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32df930be7Sderaadt.\" SUCH DAMAGE. 33df930be7Sderaadt.\" 34df930be7Sderaadt.\" @(#)date.1 8.3 (Berkeley) 4/28/95 35df930be7Sderaadt.\" 36*748ccd45Sderaadt.Dd $Mdocdate: April 29 2021 $ 37df930be7Sderaadt.Dt DATE 1 38df930be7Sderaadt.Os 39df930be7Sderaadt.Sh NAME 40df930be7Sderaadt.Nm date 41df930be7Sderaadt.Nd display or set date and time 42df930be7Sderaadt.Sh SYNOPSIS 437349792aSaaron.Nm date 44dd715b7bSderaadt.Op Fl aju 453cdedcc6Stedu.Op Fl f Ar pformat 46df930be7Sderaadt.Op Fl r Ar seconds 4780e7afe2Sderaadt.Op Fl z Ar output_zone 48df930be7Sderaadt.Op Cm + Ns Ar format 490ee8ed78Saaron.Sm off 500ee8ed78Saaron.Oo Oo Oo Oo Oo Oo 510ee8ed78Saaron.Ar cc Oc 520ee8ed78Saaron.Ar yy Oc 530ee8ed78Saaron.Ar mm Oc 540ee8ed78Saaron.Ar dd Oc 550ee8ed78Saaron.Ar HH Oc 5602b00935Sschwarze.Ar MM 5702b00935Sschwarze.Op . Ar SS 58e593fc94Sjmc.Oc 590ee8ed78Saaron.Sm on 60df930be7Sderaadt.Sh DESCRIPTION 6158c397ffSaaronWhen invoked without arguments, the 62f11c8a18Saaron.Nm 6358c397ffSaaronutility displays the current date and time. 6458c397ffSaaronOtherwise, depending on the options specified, 6558c397ffSaaron.Nm 6658c397ffSaaronwill set the date and time or print it in a user-defined way. 6758c397ffSaaron.Pp 686ec16d95SjmcChanging the system date has some risks, as described in 69bcbc4ef9Sderaadt.Xr settimeofday 2 . 706ec16d95SjmcOnly the superuser may change the date. 71df930be7Sderaadt.Pp 72df930be7SderaadtThe options are as follows: 73df930be7Sderaadt.Bl -tag -width Ds 74a635c382Sderaadt.It Fl a 75a635c382SderaadtUse the 76a635c382Sderaadt.Xr adjtime 2 77a635c382Sderaadtcall to gradually skew the local time to the 78831ed189Sjcadesired time rather than just hopping. 793cdedcc6Stedu.It Fl f Ar pformat 803cdedcc6SteduParse the specified time using 813cdedcc6Stedu.Xr strptime 3 823cdedcc6Steduwith a format string of 833cdedcc6Stedu.Ar pformat . 8495dac055Sdhartmei.It Fl j 8595dac055SdhartmeiParse the provided date and time and display the result without changing 8695dac055Sdhartmeithe clock. 87febaab32Sderaadt.It Fl r Ar seconds 88febaab32SderaadtPrint out (in specified format) the date and time represented by 89df930be7Sderaadt.Ar seconds 90df930be7Sderaadtfrom the Epoch. 91df930be7Sderaadt.It Fl u 9261208ab3SaaronDisplay or set the date in UTC (Coordinated Universal) time. 9380e7afe2Sderaadt.It Fl z Ar output_zone 9480e7afe2SderaadtJust before printing the time, change to the specified timezone; 9580e7afe2Sderaadtsee the description of 9680e7afe2Sderaadt.Ev TZ 9780e7afe2Sderaadtbelow. 9880e7afe2SderaadtThis can be used with 9980e7afe2Sderaadt.Fl j 10080e7afe2Sderaadtto easily convert time specifications from one zone to another. 101df930be7Sderaadt.El 102df930be7Sderaadt.Pp 103c9eca905SaaronAn operand with a leading plus sign 104c9eca905Saaron.Pq Sq + 105c9eca905Saaronsignals a user-defined format 106df930be7Sderaadtstring which specifies the format in which to display the date and time. 107df930be7SderaadtThe format string may contain any of the conversion specifications described 108df930be7Sderaadtin the 109df930be7Sderaadt.Xr strftime 3 110df930be7Sderaadtmanual page, as well as any arbitrary text. 11161208ab3SaaronA newline 11261208ab3Saaron.Pq Ql \en 11361208ab3Saaroncharacter is always output after the characters specified by 114df930be7Sderaadtthe format string. 115df930be7SderaadtThe format string for the default display is: 116df930be7Sderaadt.Bd -literal -offset indent 1170ee8ed78Saaron%a %b %e %H:%M:%S %Z %Y 118df930be7Sderaadt.Ed 119df930be7Sderaadt.Pp 120df930be7SderaadtIf an operand does not have a leading plus sign, it is interpreted as 121df930be7Sderaadta value for setting the system's notion of the current date and time. 122df930be7SderaadtThe canonical representation for setting the date and time is: 123df930be7Sderaadt.Pp 124df930be7Sderaadt.Bl -tag -width Ds -compact -offset indent 125d7fc02efSjmc.It Ar ccyy 126dc2cf4e4SjmcYear. 127dc2cf4e4SjmcIf yy is specified, but cc is not, 128dc2cf4e4Sjmca value for yy between 69 and 99 results in a cc value of 19. 129dc2cf4e4SjmcOtherwise, a cc value of 20 is used. 130df930be7Sderaadt.It Ar mm 131dc2cf4e4SjmcMonth: 132dc2cf4e4Sjmca number from 1 to 12. 133df930be7Sderaadt.It Ar dd 134dc2cf4e4SjmcDay: 135dc2cf4e4Sjmca number from 1 to 31. 136d7eb0c30Sbri.It Ar HH 137dc2cf4e4SjmcHour: 138dc2cf4e4Sjmca number from 0 to 23. 139d7eb0c30Sbri.It Ar MM 140dc2cf4e4SjmcMinute: 141dc2cf4e4Sjmca number from 0 to 59. 14261208ab3Saaron.It Ar SS 143dc2cf4e4SjmcSecond: 144dc2cf4e4Sjmca number from 0 to 60 145dc2cf4e4Sjmc(permitting a leap second), 146dc2cf4e4Sjmcpreceded by a period. 147df930be7Sderaadt.El 148df930be7Sderaadt.Pp 149f81d96dfSaaronEverything but the minute is optional. 150df930be7Sderaadt.Pp 15161208ab3SaaronTime changes for Daylight Saving Time, standard time, leap seconds, 152f81d96dfSaaronand leap years are handled automatically. 15341371632Sderaadt.Sh ENVIRONMENT 15461208ab3Saaron.Bl -tag -width Ds 155df930be7Sderaadt.It Ev TZ 15680e7afe2SderaadtThe time zone to use when parsing or displaying dates. 1573f20e2fbSjmcIt is normally specified as a pathname relative to 1583f20e2fbSjmc.Pa /usr/share/zoneinfo , 1593f20e2fbSjmcthough see 1603f20e2fbSjmc.Xr tzset 3 161df930be7Sderaadtfor more information. 162f395209bSderaadtIf this variable is not set, the time zone is determined based on 163f395209bSderaadt.Pa /etc/localtime , 164f395209bSderaadtwhich the administrator adjusts using 165f395209bSderaadtthe 166f395209bSderaadt.Fl l 167f395209bSderaadtoption of 168f395209bSderaadt.Xr zic 8 . 169df930be7Sderaadt.El 170df930be7Sderaadt.Sh FILES 171df930be7Sderaadt.Bl -tag -width /var/log/messages -compact 172df930be7Sderaadt.It Pa /var/log/wtmp 173f81d96dfSaaronrecord of date resets and time changes 174df930be7Sderaadt.It Pa /var/log/messages 175f81d96dfSaaronrecord of the user setting the time 176df930be7Sderaadt.El 17759a5f2b9Sjmc.Sh EXIT STATUS 1787b95d5a6Sschwarze.Ex -std 1793f4b387fSjmc.Sh EXAMPLES 180104ded78SjmcDisplay the date using the specified format string: 1813f4b387fSjmc.Bd -literal -offset indent 182104ded78Sjmc$ date "+DATE: %Y-%m-%d%nTIME: %H:%M:%S" 1833f4b387fSjmcDATE: 1987-11-21 1843f4b387fSjmcTIME: 13:36:16 1853f4b387fSjmc.Ed 1863f4b387fSjmc.Pp 1874166b027SjmcSet the date to 1884166b027SjmcJune 13, 1985, 4:27 PM: 1893f4b387fSjmc.Pp 190f5cb4eb5Sjmc.Dl # date 198506131627 1913f4b387fSjmc.Pp 1924166b027SjmcSet the time to 1934166b027Sjmc2:32 PM, 1944166b027Sjmcwithout modifying the date: 1953f4b387fSjmc.Pp 1964166b027Sjmc.Dl # date 1432 1973f20e2fbSjmc.Pp 1983f20e2fbSjmcIf the mailing list server located in California 199*748ccd45Sderaadtis being taken offline at 5:45 AM, 2003f20e2fbSjmcwork out what time it will be locally, here in Tokyo: 2013f20e2fbSjmc.Pp 2023f20e2fbSjmc.Dl $ TZ=America/Los_Angeles date -j -z Asia/Tokyo 0545 2033f4b387fSjmc.Sh SEE ALSO 2040bcf9387Sjmc.Xr adjtime 2 , 2053f4b387fSjmc.Xr gettimeofday 2 , 2063f4b387fSjmc.Xr strftime 3 , 2073f4b387fSjmc.Xr utmp 5 , 20854b4c61bSjmc.Xr ntpd 8 , 209dd715b7bSderaadt.Xr rdate 8 210df930be7Sderaadt.Sh STANDARDS 211df930be7SderaadtThe 212ac38856dSpjanzen.Nm 2130f3f4dbcSjmcutility is compliant with the 21499332e38Sjmc.St -p1003.1-2008 2150f3f4dbcSjmcspecification. 2160f3f4dbcSjmc.Pp 2170f3f4dbcSjmcThe flags 2188c02daa0Scheloha.Op Fl afjrz , 21988d23927Sschwarzeas well as the conversion specifiers 22088d23927Sschwarze.Ql \&%F , 22188d23927Sschwarze.Ql \&%G , 22288d23927Sschwarze.Ql \&%g , 22388d23927Sschwarze.Ql \&%k , 22488d23927Sschwarze.Ql \&%l , 22588d23927Sschwarze.Ql \&%R , 22688d23927Sschwarze.Ql \&%s , 22788d23927Sschwarze.Ql \&%v , 22888d23927Sschwarzeand 2292f4470e1Sjmc.Ql \&%+ , 2300f3f4dbcSjmcare extensions to that specification. 2315aa848caSjmc.Pp 2325aa848caSjmcThis implementation requires the traditional 2335aa848caSjmc.Bx 2345aa848caSjmcdate format, 2355aa848caSjmc[[[[[cc]yy]mm]dd]HH]MM[.SS], 2365aa848caSjmcwhich differs from the 2374be4abaeSjmcX/Open System Interfaces option of the 2384be4abaeSjmc.St -p1003.1-2008 2395aa848caSjmcspecification. 24007d99f0aSaaron.Sh HISTORY 24107d99f0aSaaronA 24207d99f0aSaaron.Nm 24307d99f0aSaaroncommand appeared in 24407d99f0aSaaron.At v1 . 245