2005-01-10 08:39:26 +00:00
|
|
|
.\"-
|
1994-05-26 06:18:55 +00:00
|
|
|
.\" Copyright (c) 1980, 1990, 1993
|
|
|
|
.\" The Regents of the University of California. All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" This code is derived from software contributed to Berkeley by
|
|
|
|
.\" the Institute of Electrical and Electronics Engineers, Inc.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
2017-02-28 23:42:47 +00:00
|
|
|
.\" 3. Neither the name of the University nor the names of its contributors
|
1994-05-26 06:18:55 +00:00
|
|
|
.\" may be used to endorse or promote products derived from this software
|
|
|
|
.\" without specific prior written permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
1996-12-14 05:54:15 +00:00
|
|
|
.\" @(#)date.1 8.3 (Berkeley) 4/28/95
|
1999-08-27 23:15:48 +00:00
|
|
|
.\" $FreeBSD$
|
1994-05-26 06:18:55 +00:00
|
|
|
.\"
|
2020-08-26 00:31:59 +00:00
|
|
|
.Dd August 25, 2020
|
1994-05-26 06:18:55 +00:00
|
|
|
.Dt DATE 1
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm date
|
|
|
|
.Nd display or set date and time
|
|
|
|
.Sh SYNOPSIS
|
2004-05-16 21:33:48 +00:00
|
|
|
.Nm
|
2019-04-24 05:24:10 +00:00
|
|
|
.Op Fl jnRu
|
2015-05-07 20:54:38 +00:00
|
|
|
.Op Fl r Ar seconds | Ar filename
|
2000-01-12 00:29:16 +00:00
|
|
|
.Oo
|
|
|
|
.Fl v
|
2000-12-15 17:37:31 +00:00
|
|
|
.Sm off
|
2001-06-09 11:20:31 +00:00
|
|
|
.Op Cm + | -
|
2000-12-15 17:37:31 +00:00
|
|
|
.Ar val Op Ar ymwdHMS
|
|
|
|
.Sm on
|
2000-01-12 00:29:16 +00:00
|
|
|
.Oc
|
2001-06-09 11:20:31 +00:00
|
|
|
.Ar ...
|
2004-04-06 22:03:38 +00:00
|
|
|
.Op Cm + Ns Ar output_fmt
|
|
|
|
.Nm
|
2019-03-21 06:47:23 +00:00
|
|
|
.Op Fl ju
|
2000-12-15 17:37:31 +00:00
|
|
|
.Sm off
|
2001-06-09 11:20:31 +00:00
|
|
|
.Op Oo Oo Oo Oo Ar cc Oc Ar yy Oc Ar mm Oc Ar dd Oc Ar HH
|
2000-12-15 17:37:31 +00:00
|
|
|
.Ar MM Op Ar .ss
|
|
|
|
.Sm on
|
2004-04-06 22:03:38 +00:00
|
|
|
.Nm
|
2019-03-21 06:47:23 +00:00
|
|
|
.Op Fl jRu
|
2004-05-16 21:33:48 +00:00
|
|
|
.Fl f Ar input_fmt new_date
|
2004-04-06 22:03:38 +00:00
|
|
|
.Op Cm + Ns Ar output_fmt
|
|
|
|
.Nm
|
2018-08-04 21:54:30 +00:00
|
|
|
.Op Fl jnu
|
|
|
|
.Op Fl I Ns Op Ar FMT
|
|
|
|
.Op Fl f Ar input_fmt
|
|
|
|
.Op Fl r Ar ...
|
|
|
|
.Op Fl v Ar ...
|
|
|
|
.Op Ar new_date
|
1994-05-26 06:18:55 +00:00
|
|
|
.Sh DESCRIPTION
|
2000-07-14 14:18:04 +00:00
|
|
|
When invoked without arguments, the
|
|
|
|
.Nm
|
|
|
|
utility displays the current date and time.
|
|
|
|
Otherwise, depending on the options specified,
|
|
|
|
.Nm
|
|
|
|
will set the date and time or print it in a user-defined way.
|
|
|
|
.Pp
|
2002-04-15 18:05:14 +00:00
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
utility displays the date and time read from the kernel clock.
|
|
|
|
When used to set the date and time,
|
2002-04-16 14:28:47 +00:00
|
|
|
both the kernel clock and the hardware clock are updated.
|
2002-04-15 18:05:14 +00:00
|
|
|
.Pp
|
2001-01-17 21:27:54 +00:00
|
|
|
Only the superuser may set the date,
|
|
|
|
and if the system securelevel (see
|
2007-06-02 20:15:59 +00:00
|
|
|
.Xr securelevel 7 )
|
2001-01-17 21:27:54 +00:00
|
|
|
is greater than 1,
|
|
|
|
the time may not be changed by more than 1 second.
|
1994-05-26 06:18:55 +00:00
|
|
|
.Pp
|
|
|
|
The options are as follows:
|
|
|
|
.Bl -tag -width Ds
|
1997-08-10 16:36:59 +00:00
|
|
|
.It Fl f
|
|
|
|
Use
|
2004-05-16 21:33:48 +00:00
|
|
|
.Ar input_fmt
|
2000-12-15 17:37:31 +00:00
|
|
|
as the format string to parse the
|
2004-05-16 21:33:48 +00:00
|
|
|
.Ar new_date
|
2000-12-15 17:37:31 +00:00
|
|
|
provided rather than using the default
|
|
|
|
.Sm off
|
|
|
|
.Oo Oo Oo Oo Oo
|
|
|
|
.Ar cc Oc
|
|
|
|
.Ar yy Oc
|
|
|
|
.Ar mm Oc
|
|
|
|
.Ar dd Oc
|
|
|
|
.Ar HH
|
|
|
|
.Oc Ar MM Op Ar .ss
|
|
|
|
.Sm on
|
2000-07-14 15:49:36 +00:00
|
|
|
format.
|
|
|
|
Parsing is done using
|
1997-08-10 16:36:59 +00:00
|
|
|
.Xr strptime 3 .
|
2018-08-04 21:54:30 +00:00
|
|
|
.It Fl I Ns Op Ar FMT
|
|
|
|
Use
|
|
|
|
.St -iso8601
|
|
|
|
output format.
|
|
|
|
.Ar FMT
|
|
|
|
may be omitted, in which case the default is
|
|
|
|
.Sq date .
|
|
|
|
Valid
|
|
|
|
.Ar FMT
|
|
|
|
values are
|
|
|
|
.Sq date ,
|
|
|
|
.Sq hours ,
|
|
|
|
.Sq minutes ,
|
|
|
|
and
|
|
|
|
.Sq seconds .
|
|
|
|
The date and time is formatted to the specified precision.
|
|
|
|
When
|
|
|
|
.Ar FMT
|
|
|
|
is
|
|
|
|
.Sq hours
|
|
|
|
(or the more precise
|
|
|
|
.Sq minutes
|
|
|
|
or
|
|
|
|
.Sq seconds ) ,
|
|
|
|
the
|
|
|
|
.St -iso8601
|
|
|
|
format includes the timezone.
|
1999-05-14 00:28:41 +00:00
|
|
|
.It Fl j
|
2000-07-14 15:49:36 +00:00
|
|
|
Do not try to set the date.
|
|
|
|
This allows you to use the
|
1999-05-14 00:28:41 +00:00
|
|
|
.Fl f
|
|
|
|
flag in addition to the
|
|
|
|
.Cm +
|
|
|
|
option to convert one date format to another.
|
2020-08-26 00:31:59 +00:00
|
|
|
Note that any date or time components unspecified by the
|
|
|
|
.Fl f
|
|
|
|
format string take their values from the current time.
|
2019-04-24 05:24:10 +00:00
|
|
|
.It Fl n
|
|
|
|
Obsolete flag, accepted and ignored for compatibility.
|
2014-04-26 13:05:56 +00:00
|
|
|
.It Fl R
|
2017-12-07 01:57:27 +00:00
|
|
|
Use RFC 2822 date and time output format.
|
|
|
|
This is equivalent to using
|
2014-04-26 13:05:56 +00:00
|
|
|
.Dq Li %a, %d %b %Y \&%T %z
|
|
|
|
as
|
|
|
|
.Ar output_fmt
|
|
|
|
while
|
|
|
|
.Ev LC_TIME
|
|
|
|
is set to the
|
|
|
|
.Dq C
|
|
|
|
locale .
|
2000-07-14 14:18:04 +00:00
|
|
|
.It Fl r Ar seconds
|
2000-07-15 14:55:54 +00:00
|
|
|
Print the date and time represented by
|
|
|
|
.Ar seconds ,
|
|
|
|
where
|
1994-05-26 06:18:55 +00:00
|
|
|
.Ar seconds
|
2000-07-15 14:55:54 +00:00
|
|
|
is the number of seconds since the Epoch
|
2000-07-28 02:51:43 +00:00
|
|
|
(00:00:00 UTC, January 1, 1970;
|
2000-03-07 20:54:17 +00:00
|
|
|
see
|
2000-07-28 02:51:43 +00:00
|
|
|
.Xr time 3 ) ,
|
|
|
|
and can be specified in decimal, octal, or hex.
|
2015-05-07 20:54:38 +00:00
|
|
|
.It Fl r Ar filename
|
|
|
|
Print the date and time of the last modification of
|
|
|
|
.Ar filename .
|
1994-05-26 06:18:55 +00:00
|
|
|
.It Fl u
|
|
|
|
Display or set the date in
|
2000-05-19 18:02:25 +00:00
|
|
|
.Tn UTC
|
2000-07-14 14:18:04 +00:00
|
|
|
(Coordinated Universal) time.
|
1997-08-09 22:34:06 +00:00
|
|
|
.It Fl v
|
2001-03-16 02:20:24 +00:00
|
|
|
Adjust (i.e., take the current date and display the result of the
|
|
|
|
adjustment; not actually set the date) the second, minute, hour, month
|
|
|
|
day, week day, month or year according to
|
2001-07-15 07:53:42 +00:00
|
|
|
.Ar val .
|
1997-08-04 03:37:07 +00:00
|
|
|
If
|
|
|
|
.Ar val
|
2000-07-14 15:49:36 +00:00
|
|
|
is preceded with a plus or minus sign,
|
|
|
|
the date is adjusted forwards or backwards according to the remaining string,
|
|
|
|
otherwise the relevant part of the date is set.
|
|
|
|
The date can be adjusted as many times as required using these flags.
|
|
|
|
Flags are processed in the order given.
|
1997-08-04 03:37:07 +00:00
|
|
|
.Pp
|
2000-04-12 13:35:17 +00:00
|
|
|
When setting values
|
2001-08-07 15:48:51 +00:00
|
|
|
(rather than adjusting them),
|
2000-04-12 13:35:17 +00:00
|
|
|
seconds are in the range 0-59, minutes are in the range 0-59, hours are
|
2002-10-03 14:11:29 +00:00
|
|
|
in the range 0-23, month days are in the range 1-31, week days are in the
|
2001-08-07 15:48:51 +00:00
|
|
|
range 0-6 (Sun-Sat),
|
|
|
|
months are in the range 1-12 (Jan-Dec)
|
2000-01-12 00:29:16 +00:00
|
|
|
and years are in the range 80-38 or 1980-2038.
|
1997-08-09 22:34:06 +00:00
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Ar val
|
|
|
|
is numeric, one of either
|
|
|
|
.Ar y ,
|
|
|
|
.Ar m ,
|
|
|
|
.Ar w ,
|
|
|
|
.Ar d ,
|
1999-03-09 09:38:54 +00:00
|
|
|
.Ar H ,
|
1997-08-09 22:34:06 +00:00
|
|
|
.Ar M
|
1999-03-09 09:38:54 +00:00
|
|
|
or
|
|
|
|
.Ar S
|
1997-08-09 22:34:06 +00:00
|
|
|
must be used to specify which part of the date is to be adjusted.
|
1997-08-04 03:37:07 +00:00
|
|
|
.Pp
|
|
|
|
The week day or month may be specified using a name rather than a
|
2000-07-14 15:49:36 +00:00
|
|
|
number.
|
|
|
|
If a name is used with the plus
|
2001-08-07 15:48:51 +00:00
|
|
|
(or minus)
|
2000-01-12 00:29:16 +00:00
|
|
|
sign, the date will be put forwards
|
2001-08-07 15:48:51 +00:00
|
|
|
(or backwards)
|
2000-01-12 00:29:16 +00:00
|
|
|
to the next
|
2001-08-07 15:48:51 +00:00
|
|
|
(previous)
|
2000-07-14 15:49:36 +00:00
|
|
|
date that matches the given week day or month.
|
|
|
|
This will not adjust the date,
|
1997-08-04 03:37:07 +00:00
|
|
|
if the given week day or month is the same as the current one.
|
|
|
|
.Pp
|
2000-04-12 13:35:17 +00:00
|
|
|
When a date is adjusted to a specific value or in units greater than hours,
|
2000-07-14 15:38:38 +00:00
|
|
|
daylight savings time considerations are ignored.
|
2000-07-14 14:18:04 +00:00
|
|
|
Adjustments in units of hours or less honor daylight saving time.
|
2000-04-12 13:35:17 +00:00
|
|
|
So, assuming the current date is March 26, 0:30 and that the DST adjustment
|
|
|
|
means that the clock goes forward at 01:00 to 02:00, using
|
|
|
|
.Fl v No +1H
|
|
|
|
will adjust the date to March 26, 2:30.
|
|
|
|
Likewise, if the date is October 29, 0:30 and the DST adjustment means that
|
|
|
|
the clock goes back at 02:00 to 01:00, using
|
|
|
|
.Fl v No +3H
|
2000-06-28 09:20:06 +00:00
|
|
|
will be necessary to reach October 29, 2:30.
|
2000-04-12 13:35:17 +00:00
|
|
|
.Pp
|
2005-02-13 22:25:33 +00:00
|
|
|
When the date is adjusted to a specific value that does not actually exist
|
2001-08-07 15:48:51 +00:00
|
|
|
(for example March 26, 1:30 BST 2000 in the Europe/London timezone),
|
2000-04-12 13:35:17 +00:00
|
|
|
the date will be silently adjusted forwards in units of one hour until it
|
|
|
|
reaches a valid time.
|
|
|
|
When the date is adjusted to a specific value that occurs twice
|
2001-08-07 15:48:51 +00:00
|
|
|
(for example October 29, 1:30 2000),
|
2000-04-12 13:35:17 +00:00
|
|
|
the resulting timezone will be set so that the date matches the earlier of
|
|
|
|
the two times.
|
|
|
|
.Pp
|
2010-06-04 06:56:58 +00:00
|
|
|
It is not possible to adjust a date to an invalid absolute day, so using
|
|
|
|
the switches
|
|
|
|
.Fl v No 31d Fl v No 12m
|
|
|
|
will simply fail five months of the year.
|
|
|
|
It is therefore usual to set the month before setting the day; using
|
|
|
|
.Fl v No 12m Fl v No 31d
|
|
|
|
always works.
|
|
|
|
.Pp
|
2004-08-09 13:43:39 +00:00
|
|
|
Adjusting the date by months is inherently ambiguous because
|
|
|
|
a month is a unit of variable length depending on the current date.
|
|
|
|
This kind of date adjustment is applied in the most intuitive way.
|
|
|
|
First of all,
|
|
|
|
.Nm
|
|
|
|
tries to preserve the day of the month.
|
|
|
|
If it is impossible because the target month is shorter than the present one,
|
|
|
|
the last day of the target month will be the result.
|
|
|
|
For example, using
|
|
|
|
.Fl v No +1m
|
|
|
|
on May 31 will adjust the date to June 30, while using the same option
|
|
|
|
on January 30 will result in the date adjusted to the last day of February.
|
|
|
|
This approach is also believed to make the most sense for shell scripting.
|
|
|
|
Nevertheless, be aware that going forth and back by the same number of
|
|
|
|
months may take you to a different date.
|
|
|
|
.Pp
|
1997-08-04 03:37:07 +00:00
|
|
|
Refer to the examples below for further details.
|
1994-05-26 06:18:55 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
2000-07-18 12:02:15 +00:00
|
|
|
An operand with a leading plus
|
2000-07-14 15:49:36 +00:00
|
|
|
.Pq Sq +
|
|
|
|
sign signals a user-defined format string
|
|
|
|
which specifies the format in which to display the date and time.
|
|
|
|
The format string may contain any of the conversion specifications
|
2001-07-15 07:53:42 +00:00
|
|
|
described in the
|
1994-05-26 06:18:55 +00:00
|
|
|
.Xr strftime 3
|
|
|
|
manual page, as well as any arbitrary text.
|
2000-07-14 14:18:04 +00:00
|
|
|
A newline
|
|
|
|
.Pq Ql \en
|
|
|
|
character is always output after the characters specified by
|
1996-12-14 05:54:15 +00:00
|
|
|
the format string.
|
2000-01-12 00:29:16 +00:00
|
|
|
The format string for the default display is
|
|
|
|
.Dq +%+ .
|
1994-05-26 06:18:55 +00:00
|
|
|
.Pp
|
|
|
|
If an operand does not have a leading plus sign, it is interpreted as
|
|
|
|
a value for setting the system's notion of the current date and time.
|
|
|
|
The canonical representation for setting the date and time is:
|
|
|
|
.Pp
|
|
|
|
.Bl -tag -width Ds -compact -offset indent
|
1999-11-10 13:34:39 +00:00
|
|
|
.It Ar cc
|
2000-01-12 00:29:16 +00:00
|
|
|
Century
|
2001-08-07 15:48:51 +00:00
|
|
|
(either 19 or 20)
|
2000-01-12 00:29:16 +00:00
|
|
|
prepended to the abbreviated year.
|
1994-05-26 06:18:55 +00:00
|
|
|
.It Ar yy
|
2000-01-12 00:29:16 +00:00
|
|
|
Year in abbreviated form
|
2004-07-02 21:04:19 +00:00
|
|
|
(e.g., 89 for 1989, 06 for 2006).
|
1994-05-26 06:18:55 +00:00
|
|
|
.It Ar mm
|
2000-07-14 15:49:36 +00:00
|
|
|
Numeric month, a number from 1 to 12.
|
1994-05-26 06:18:55 +00:00
|
|
|
.It Ar dd
|
|
|
|
Day, a number from 1 to 31.
|
1997-08-10 16:36:59 +00:00
|
|
|
.It Ar HH
|
1994-05-26 06:18:55 +00:00
|
|
|
Hour, a number from 0 to 23.
|
1997-08-10 16:36:59 +00:00
|
|
|
.It Ar MM
|
1994-05-26 06:18:55 +00:00
|
|
|
Minutes, a number from 0 to 59.
|
2000-07-14 15:49:36 +00:00
|
|
|
.It Ar ss
|
2018-06-01 22:37:59 +00:00
|
|
|
Seconds, a number from 0 to 60
|
|
|
|
(59 plus a potential leap second).
|
1994-05-26 06:18:55 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
Everything but the minutes is optional.
|
|
|
|
.Pp
|
2000-07-14 14:18:04 +00:00
|
|
|
Time changes for Daylight Saving Time, standard time, leap seconds,
|
|
|
|
and leap years are handled automatically.
|
2005-01-16 16:41:59 +00:00
|
|
|
.Sh ENVIRONMENT
|
|
|
|
The following environment variables affect the execution of
|
|
|
|
.Nm :
|
|
|
|
.Bl -tag -width Ds
|
|
|
|
.It Ev TZ
|
|
|
|
The timezone to use when displaying dates.
|
|
|
|
The normal format is a pathname relative to
|
|
|
|
.Pa /usr/share/zoneinfo .
|
|
|
|
For example, the command
|
|
|
|
.Dq TZ=America/Los_Angeles date
|
|
|
|
displays the current time in California.
|
|
|
|
See
|
|
|
|
.Xr environ 7
|
|
|
|
for more information.
|
|
|
|
.El
|
|
|
|
.Sh FILES
|
|
|
|
.Bl -tag -width /var/log/messages -compact
|
2010-01-21 17:25:12 +00:00
|
|
|
.It Pa /var/log/utx.log
|
2005-01-16 16:41:59 +00:00
|
|
|
record of date resets and time changes
|
|
|
|
.It Pa /var/log/messages
|
|
|
|
record of the user setting the time
|
|
|
|
.El
|
|
|
|
.Sh EXIT STATUS
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
utility exits 0 on success, 1 if unable to set the date, and 2
|
|
|
|
if able to set the local date, but unable to set it globally.
|
1994-05-26 06:18:55 +00:00
|
|
|
.Sh EXAMPLES
|
|
|
|
The command:
|
2003-02-23 01:47:49 +00:00
|
|
|
.Pp
|
|
|
|
.Dl "date ""+DATE: %Y-%m-%d%nTIME: %H:%M:%S"""
|
1994-05-26 06:18:55 +00:00
|
|
|
.Pp
|
|
|
|
will display:
|
|
|
|
.Bd -literal -offset indent
|
1997-10-03 18:09:17 +00:00
|
|
|
DATE: 1987-11-21
|
1994-05-26 06:18:55 +00:00
|
|
|
TIME: 13:36:16
|
|
|
|
.Ed
|
|
|
|
.Pp
|
2000-06-22 10:02:33 +00:00
|
|
|
In the Europe/London timezone, the command:
|
2003-02-23 01:47:49 +00:00
|
|
|
.Pp
|
|
|
|
.Dl "date -v1m -v+1y"
|
1997-08-04 03:37:07 +00:00
|
|
|
.Pp
|
|
|
|
will display:
|
2003-02-23 01:47:49 +00:00
|
|
|
.Pp
|
|
|
|
.Dl "Sun Jan 4 04:15:24 GMT 1998"
|
1997-08-04 03:37:07 +00:00
|
|
|
.Pp
|
2004-07-03 00:06:28 +00:00
|
|
|
where it is currently
|
|
|
|
.Li "Mon Aug 4 04:15:24 BST 1997" .
|
1997-08-04 03:37:07 +00:00
|
|
|
.Pp
|
|
|
|
The command:
|
2003-02-23 01:47:49 +00:00
|
|
|
.Pp
|
|
|
|
.Dl "date -v1d -v3m -v0y -v-1d"
|
1997-08-04 03:37:07 +00:00
|
|
|
.Pp
|
|
|
|
will display the last day of February in the year 2000:
|
2003-02-23 01:47:49 +00:00
|
|
|
.Pp
|
|
|
|
.Dl "Tue Feb 29 03:18:00 GMT 2000"
|
1997-08-04 03:37:07 +00:00
|
|
|
.Pp
|
2010-06-04 06:56:58 +00:00
|
|
|
So will the command:
|
2004-08-09 13:43:39 +00:00
|
|
|
.Pp
|
2010-06-04 06:56:58 +00:00
|
|
|
.Dl "date -v3m -v30d -v0y -v-1m"
|
2004-08-09 13:43:39 +00:00
|
|
|
.Pp
|
|
|
|
because there is no such date as the 30th of February.
|
|
|
|
.Pp
|
1997-08-04 03:37:07 +00:00
|
|
|
The command:
|
2003-02-23 01:47:49 +00:00
|
|
|
.Pp
|
|
|
|
.Dl "date -v1d -v+1m -v-1d -v-fri"
|
1997-08-04 03:37:07 +00:00
|
|
|
.Pp
|
1998-04-20 21:06:38 +00:00
|
|
|
will display the last Friday of the month:
|
2003-02-23 01:47:49 +00:00
|
|
|
.Pp
|
|
|
|
.Dl "Fri Aug 29 04:31:11 BST 1997"
|
1997-08-04 03:37:07 +00:00
|
|
|
.Pp
|
2004-07-03 00:06:28 +00:00
|
|
|
where it is currently
|
|
|
|
.Li "Mon Aug 4 04:31:11 BST 1997" .
|
1997-08-04 03:37:07 +00:00
|
|
|
.Pp
|
|
|
|
The command:
|
2003-02-23 01:47:49 +00:00
|
|
|
.Pp
|
|
|
|
.Dl "date 8506131627"
|
1994-05-26 06:18:55 +00:00
|
|
|
.Pp
|
|
|
|
sets the date to
|
|
|
|
.Dq Li "June 13, 1985, 4:27 PM" .
|
2003-02-18 23:12:55 +00:00
|
|
|
.Pp
|
2003-02-23 01:47:49 +00:00
|
|
|
.Dl "date ""+%Y%m%d%H%M.%S"""
|
|
|
|
.Pp
|
|
|
|
may be used on one machine to print out the date
|
|
|
|
suitable for setting on another.
|
2004-05-16 21:33:48 +00:00
|
|
|
.Qq ( Li "+%m%d%H%M%Y.%S"
|
|
|
|
for use on
|
|
|
|
.Tn Linux . )
|
1994-05-26 06:18:55 +00:00
|
|
|
.Pp
|
|
|
|
The command:
|
2003-02-23 01:47:49 +00:00
|
|
|
.Pp
|
|
|
|
.Dl "date 1432"
|
1994-05-26 06:18:55 +00:00
|
|
|
.Pp
|
|
|
|
sets the time to
|
|
|
|
.Li "2:32 PM" ,
|
|
|
|
without modifying the date.
|
2004-07-17 00:26:31 +00:00
|
|
|
.Pp
|
2018-08-04 21:54:30 +00:00
|
|
|
The command
|
|
|
|
.Pp
|
|
|
|
.Dl "TZ=America/Los_Angeles date -Iseconds -r 1533415339"
|
|
|
|
.Pp
|
|
|
|
will display
|
|
|
|
.Pp
|
|
|
|
.Dl "2018-08-04T13:42:19-07:00"
|
|
|
|
.Pp
|
2004-07-17 00:26:31 +00:00
|
|
|
Finally the command:
|
|
|
|
.Pp
|
|
|
|
.Dl "date -j -f ""%a %b %d %T %Z %Y"" ""`date`"" ""+%s"""
|
|
|
|
.Pp
|
2005-01-09 19:54:23 +00:00
|
|
|
can be used to parse the output from
|
2004-07-17 00:26:31 +00:00
|
|
|
.Nm
|
2005-01-09 19:54:23 +00:00
|
|
|
and express it in Epoch time.
|
1994-05-26 06:18:55 +00:00
|
|
|
.Sh DIAGNOSTICS
|
2018-08-04 21:54:30 +00:00
|
|
|
It is invalid to combine the
|
|
|
|
.Fl I
|
|
|
|
flag with either
|
|
|
|
.Fl R
|
|
|
|
or an output format
|
|
|
|
.Dq ( + Ns ... )
|
|
|
|
operand.
|
|
|
|
If this occurs,
|
|
|
|
.Nm
|
|
|
|
prints:
|
|
|
|
.Ql multiple output formats specified
|
|
|
|
and exits with an error status.
|
2005-01-16 16:41:59 +00:00
|
|
|
.Sh SEE ALSO
|
2005-11-01 19:31:25 +00:00
|
|
|
.Xr locale 1 ,
|
2005-01-16 16:41:59 +00:00
|
|
|
.Xr gettimeofday 2 ,
|
2010-01-21 17:25:12 +00:00
|
|
|
.Xr getutxent 3 ,
|
2005-01-16 16:41:59 +00:00
|
|
|
.Xr strftime 3 ,
|
2019-03-21 06:47:23 +00:00
|
|
|
.Xr strptime 3
|
2005-01-16 16:41:59 +00:00
|
|
|
.Rs
|
|
|
|
.%T "TSP: The Time Synchronization Protocol for UNIX 4.3BSD"
|
|
|
|
.%A R. Gusella
|
|
|
|
.%A S. Zatti
|
|
|
|
.Re
|
1994-05-26 06:18:55 +00:00
|
|
|
.Sh STANDARDS
|
|
|
|
The
|
1998-05-06 06:51:42 +00:00
|
|
|
.Nm
|
2000-07-14 14:18:04 +00:00
|
|
|
utility is expected to be compatible with
|
1994-05-26 06:18:55 +00:00
|
|
|
.St -p1003.2 .
|
2005-11-01 19:31:25 +00:00
|
|
|
The
|
2019-03-21 06:47:23 +00:00
|
|
|
.Fl d , f , I , j , r , t ,
|
2005-11-01 19:31:25 +00:00
|
|
|
and
|
|
|
|
.Fl v
|
|
|
|
options are all extensions to the standard.
|
2018-08-04 21:54:30 +00:00
|
|
|
.Pp
|
|
|
|
The format selected by the
|
|
|
|
.Fl I
|
|
|
|
flag is compatible with
|
|
|
|
.St -iso8601 .
|
1996-08-29 18:06:19 +00:00
|
|
|
.Sh HISTORY
|
|
|
|
A
|
|
|
|
.Nm
|
|
|
|
command appeared in
|
|
|
|
.At v1 .
|
2018-08-04 21:54:30 +00:00
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fl I
|
|
|
|
flag was added in
|
|
|
|
.Fx 12.0 .
|