| 1 | .\" Copyright (c) 1980, 1990 The Regents of the University of California. |
| 2 | .\" 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 6.16 (Berkeley) 7/30/91 |
| 36 | .\" |
| 37 | .Dd July 30, 1991 |
| 38 | .Dt DATE 1 |
| 39 | .Os |
| 40 | .Sh NAME |
| 41 | .Nm date |
| 42 | .Nd Display or set date and time |
| 43 | .Sh SYNOPSIS |
| 44 | .Nm date |
| 45 | .Op Fl d Ar dst |
| 46 | .Op Fl r Ar seconds |
| 47 | .Op Fl t Ar minutes_west |
| 48 | .Op Fl nu |
| 49 | .Op Cm + Ns Ar format |
| 50 | .Op [yy[mm[dd[hh]]]]mm[\&.ss] |
| 51 | .Sh DESCRIPTION |
| 52 | .Nm Date |
| 53 | displays the current date and time when invoked without arguments. |
| 54 | Providing arguments will format the date and time in a user-defined |
| 55 | way or set the date. |
| 56 | Only the superuser may set the date. |
| 57 | .Pp |
| 58 | The options are as follows: |
| 59 | .Bl -tag -width Ds |
| 60 | .It Fl d |
| 61 | Set the kernel's values for daylight savings time. |
| 62 | If |
| 63 | .Ar dst |
| 64 | is non-zero, future calls |
| 65 | to |
| 66 | .Xr gettimeofday 2 |
| 67 | will return a non-zero |
| 68 | .Ql tz_dsttime . |
| 69 | .It Fl n |
| 70 | The utility |
| 71 | .Xr timed 8 |
| 72 | is used to synchronize the clocks of groups of machines. |
| 73 | By default, if |
| 74 | .Xr timed |
| 75 | is running, |
| 76 | .Nm date |
| 77 | will set the time on all of the machines in the local group. |
| 78 | The |
| 79 | .Fl n |
| 80 | option stops |
| 81 | .Nm date |
| 82 | from setting the time for other than the current machine. |
| 83 | .It Fl r |
| 84 | Print out the date and time for |
| 85 | .Ar seconds |
| 86 | from the Epoch. |
| 87 | .It Fl t |
| 88 | Set the kernel's values for minutes west of |
| 89 | .Tn GMT . |
| 90 | .Ar Minutes_west |
| 91 | specifies the number of minutes returned in |
| 92 | .Ql tz_minuteswest |
| 93 | by future calls to |
| 94 | .Xr gettimeofday 2 . |
| 95 | .It Fl u |
| 96 | Display or set the date in |
| 97 | .Tn UCT |
| 98 | (universal) time. |
| 99 | .El |
| 100 | .Pp |
| 101 | An operand with a leading plus (``+'') sign signals a user-defined format |
| 102 | string which specifies the format in which to display the date and time. |
| 103 | The format string may contain any of the conversion specifications described |
| 104 | in the |
| 105 | .Xr strftime 3 |
| 106 | manual page, as well as any arbitrary text. |
| 107 | The format string for the default display is: |
| 108 | .Bd -literal -offset indent |
| 109 | ``%a %b %e %H:%M:%S %Z n''. |
| 110 | .Ed |
| 111 | .Pp |
| 112 | If an operand does not have a leading plus sign, it is interpreted as |
| 113 | a value for setting the system's notion of the current date and time. |
| 114 | The canonical representation for setting the date and time: |
| 115 | .Pp |
| 116 | .Bl -tag -width Ds -compact -offset indent |
| 117 | .It Ar yy |
| 118 | Year in abbreviated form (.e.g 89 for 1989). |
| 119 | .It Ar mm |
| 120 | Numeric month. |
| 121 | A number from 1 to 12. |
| 122 | .It Ar dd |
| 123 | Day, a number from 1 to 31. |
| 124 | .It Ar hh |
| 125 | Hour, a number from 0 to 23. |
| 126 | .It Ar mm |
| 127 | Minutes, a number from 0 to 59. |
| 128 | .It Ar .ss |
| 129 | Seconds, a number from 0 to 59. |
| 130 | .El |
| 131 | .Pp |
| 132 | Everything but the minutes are optional. |
| 133 | .Pp |
| 134 | Time changes for Daylight Saving and Standard time and leap seconds |
| 135 | and years are handled automatically. |
| 136 | .Sh EXAMPLES |
| 137 | The command: |
| 138 | .Bd -literal -offset indent |
| 139 | date ``+DATE: %m/%d/%y%nTIME: %H:%M:%n'' |
| 140 | .Ed |
| 141 | .Pp |
| 142 | will display: |
| 143 | .Bd -literal -offset indent |
| 144 | DATE: 11/21/87 |
| 145 | TIME: 13:36:16 |
| 146 | .Ed |
| 147 | .Pp |
| 148 | The command: |
| 149 | .Bd -literal -offset indent |
| 150 | date 8506131627 |
| 151 | .Ed |
| 152 | .Pp |
| 153 | sets the date to |
| 154 | .Dq Li "June 13 1985, 4:27 PM" . |
| 155 | .Pp |
| 156 | The command: |
| 157 | .Bd -literal -offset indent |
| 158 | date 1432 |
| 159 | .Ed |
| 160 | .Pp |
| 161 | sets the time to |
| 162 | .Li "2:32 PM" , |
| 163 | without modifying the date. |
| 164 | .Sh FILES |
| 165 | .Bl -tag -width /var/log/messages -compact |
| 166 | .It Pa /var/log/wtmp |
| 167 | A record of date resets and time changes. |
| 168 | .It Pa /var/log/messages |
| 169 | A record of the user setting the time. |
| 170 | .El |
| 171 | .Sh SEE ALSO |
| 172 | .Xr gettimeofday 2 , |
| 173 | .Xr strftime 3 , |
| 174 | .Xr utmp 5 , |
| 175 | .Xr timed 8 |
| 176 | .Rs |
| 177 | .%T "TSP: The Time Synchronization Protocol for UNIX 4.3BSD" |
| 178 | .%A R. Gusella |
| 179 | .%A S. Zatti |
| 180 | .Re |
| 181 | .Sh DIAGNOSTICS |
| 182 | Exit status is 0 on success, 1 if unable to set the date, and 2 |
| 183 | if able to set the local date but failing to set it globally. |
| 184 | .Pp |
| 185 | Occasionally, when |
| 186 | .Xr timed |
| 187 | synchronizes the time on many hosts, the setting of a new time value may |
| 188 | require more than a few seconds. |
| 189 | On these occasions, |
| 190 | .Nm date |
| 191 | prints: |
| 192 | .Ql Network time being set . |
| 193 | The message |
| 194 | .Ql Communication error with timed |
| 195 | occurs when the communication |
| 196 | between |
| 197 | .Nm date |
| 198 | and |
| 199 | .Xr timed |
| 200 | fails. |
| 201 | .Sh BUGS |
| 202 | The system attempts to keep the date in a format closely compatible |
| 203 | with |
| 204 | .Tn VMS . |
| 205 | .Tn VMS , |
| 206 | however, uses local time (rather than |
| 207 | .Tn GMT ) |
| 208 | and does not understand |
| 209 | daylight-saving time. |
| 210 | Thus, if you use both |
| 211 | .Tn UNIX |
| 212 | and |
| 213 | .Tn VMS , |
| 214 | .Tn VMS |
| 215 | will be running on |
| 216 | .Tn GMT . |
| 217 | .Sh HISTORY |
| 218 | The |
| 219 | .Nm date |
| 220 | command is expected to be compatible with |
| 221 | .St p1003.2 . |