.\" $OpenBSD: date.1,v 1.45 2006/01/08 00:19:55 jmc Exp $ .\" $NetBSD: date.1,v 1.12 1996/03/12 04:32:37 phil Exp $ .\" .\" 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. .\" 3. Neither the name of the University nor the names of its contributors .\" 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. .\" .\" @(#)date.1 8.3 (Berkeley) 4/28/95 .\" .Dd April 28, 1995 .Dt DATE 1 .Os .Sh NAME .Nm date .Nd display or set date and time .Sh SYNOPSIS .Nm date .Op Fl ajnu .Op Fl d Ar dst .Op Fl r Ar seconds .Op Fl t Ar minutes_west .Op Cm + Ns Ar format .Sm off .Oo 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 Oc .Sm on .Sh DESCRIPTION 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 Only the superuser may set the date. .Pp The options are as follows: .Bl -tag -width Ds .It Fl a Use the .Xr adjtime 2 call to gradually skew the local time to the remote time rather than just hopping. .It Fl d Ar dst Set the system's value for Daylight Saving Time. If .Ar dst is non-zero, future calls to .Xr gettimeofday 2 will return a non-zero value for .Fa tz_dsttime . .It Fl j Parse the provided date and time and display the result without changing the clock. .It Fl n By default, if the .Xr timed 8 daemon is running, .Nm sets the time on all of the machines in the local group. The .Fl n option suppresses this behavior and causes the time to be set only on the current machine. .It Fl r Ar seconds Print out (in specified format) the date and time represented by .Ar seconds from the Epoch. .It Fl t Ar minutes_west Set the system's value for minutes west of .Tn GMT . .Ar minutes_west specifies the number of minutes returned in .Fa tz_minuteswest by future calls to .Xr gettimeofday 2 . .It Fl u Display or set the date in UTC (Coordinated Universal) time. .El .Pp An operand with a leading plus sign .Pq Sq + 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 described in the .Xr strftime 3 manual page, as well as any arbitrary text. A newline .Pq Ql \en character is always output after the characters specified by the format string. The format string for the default display is: .Bd -literal -offset indent %a %b %e %H:%M:%S %Z %Y .Ed .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 .It Ar ccyy Year: the first two digits (representing the century) may be omitted for non-ambiguous years (1969\-2068). .It Ar mm Numeric month: a number from 1 to 12. .It Ar dd Day: a number from 1 to 31. .It Ar HH Hour: a number from 0 to 23. .It Ar MM Minute: a number from 0 to 59. .It Ar SS Second: a number from 0 to 61 (59 plus a maximum of two leap seconds). .El .Pp Everything but the minute is optional. .Pp Time changes for Daylight Saving Time, standard time, leap seconds, and leap years are handled automatically. .Sh ENVIRONMENT .Bl -tag -width Ds .It Ev TZ The time zone to use when displaying dates. See .Xr environ 7 for more information. If this variable is not set, the time zone is determined based on .Pa /etc/localtime , which the administrator adjusts using the .Fl l option of .Xr zic 8 . .El .Sh FILES .Bl -tag -width /var/log/messages -compact .It Pa /var/log/wtmp record of date resets and time changes .It Pa /var/log/messages record of the user setting the time .El .Sh EXAMPLES Display the date using the specified format string: .Bd -literal -offset indent $ date "+DATE: %Y-%m-%d%nTIME: %H:%M:%S" DATE: 1987-11-21 TIME: 13:36:16 .Ed .Pp Set the date to June 13, 1985, 4:27 PM: .Pp .Dl # date 8506131627 .Pp Set the time to 2:32 PM, without modifying the date: .Pp .Dl # date 1432 .Sh DIAGNOSTICS Exit status is 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. .Pp Occasionally, when .Xr timed 8 synchronizes the time on many hosts, the setting of a new time value may require more than a few seconds. On these occasions, .Nm prints: .Dq Network time being set . The message .Dq Communication error with timed occurs when the communication between .Nm and .Xr timed 8 fails. .Sh SEE ALSO .Xr adjtime 2 , .Xr gettimeofday 2 , .Xr strftime 3 , .Xr utmp 5 , .Xr ntpd 8 , .Xr rdate 8 , .Xr timed 8 .Rs .%T "TSP: The Time Synchronization Protocol for UNIX 4.3BSD" .%A R. Gusella .%A S. Zatti .Re .Sh STANDARDS The .Nm utility is expected to be compatible with .St -p1003.2 . .Sh HISTORY A .Nm command appeared in .At v1 .