| 1 | .\" Copyright (c) 1980, 1990 The Regents of the University of California. |
| 2 | .\" All rights reserved. |
| 3 | .\" |
| 4 | .\" %sccs.include.redist.man% |
| 5 | .\" |
| 6 | .\" @(#)date.1 6.12 (Berkeley) %G% |
| 7 | .\" |
| 8 | .Dd |
| 9 | .Dt DATE 1 |
| 10 | .Os BSD 4.4 |
| 11 | .Sh NAME |
| 12 | .Nm date |
| 13 | .Nd display or set date and time |
| 14 | .Sh SYNOPSIS |
| 15 | .Nm date |
| 16 | .Op Fl nu |
| 17 | .Op Fl d Ar dst |
| 18 | .Op Fl r Ar seconds |
| 19 | .Op Fl t Ar minutes_west |
| 20 | .Op +format |
| 21 | .Op [yy[mm[dd[hh]]]]mm[\&.ss] |
| 22 | .Sh DESCRIPTION |
| 23 | .Nm Date |
| 24 | displays the current date and time when invoked without arguments. |
| 25 | Providing arguments will format the date and time in a user-defined |
| 26 | way or set the date. |
| 27 | Only the superuser may set the date. |
| 28 | .Pp |
| 29 | The options are as follows: |
| 30 | .Pp |
| 31 | .Tw Ds |
| 32 | .Tp Fl d |
| 33 | Set the kernel's values for daylight savings time. |
| 34 | If |
| 35 | .Ar dst |
| 36 | is non-zero, future calls |
| 37 | to |
| 38 | .Xr gettimeofday 2 |
| 39 | will return a non-zero |
| 40 | .Ql tz_dsttime . |
| 41 | .Tp Fl n |
| 42 | The utility |
| 43 | .Xr timed 8 |
| 44 | is used to synchronize the clocks of groups of machines. |
| 45 | By default, if |
| 46 | .Xr timed |
| 47 | is running, |
| 48 | .Nm date |
| 49 | will set the time on all of the machines in the local group. |
| 50 | The |
| 51 | .Fl n |
| 52 | option stops |
| 53 | .Nm date |
| 54 | from setting the time for other than the current machine. |
| 55 | .Tp Fl r |
| 56 | Print out the date and time for |
| 57 | .Ar seconds |
| 58 | from the Epoch. |
| 59 | .Tp Fl t |
| 60 | Set the kernel's values for minutes west of GMT. |
| 61 | .Ar Minutes_west |
| 62 | specifies the number of minutes returned in |
| 63 | .Ql tz_minuteswest |
| 64 | by future calls to |
| 65 | .Xr gettimeofday 2 . |
| 66 | .Tp Fl u |
| 67 | Display or set the date in UCT (universal) time. |
| 68 | .Tp |
| 69 | .Pp |
| 70 | An operand with a leading plus (``+'') sign signals a user-defined format |
| 71 | string which specifies the format in which to display the date and time. |
| 72 | The format string may contain any of the conversion specifications described |
| 73 | in the |
| 74 | .Xr strftime 3 |
| 75 | manual page, as well as any arbitrary text. |
| 76 | The format string for the default display is: |
| 77 | .Pp |
| 78 | .Dl ``%a %b %e %H:%M:%S %Z %Y\en''. |
| 79 | .Pp |
| 80 | If an operand does not have a leading plus sign, it is interpreted as |
| 81 | a value for setting the system's notion of the current date and time. |
| 82 | The canonical representation for setting the date and time: |
| 83 | .Dw Ds |
| 84 | .Dp Ar yy |
| 85 | Year in abbreviated form (.e.g 89 for 1989). |
| 86 | .Dp Ar mm |
| 87 | Numeric month. |
| 88 | A number from 1 to 12. |
| 89 | .Dp Ar dd |
| 90 | Day, a number from 1 to 31. |
| 91 | .Dp Ar hh |
| 92 | Hour, a number from 0 to 23. |
| 93 | .Dp Ar mm |
| 94 | Minutes, a number from 0 to 59. |
| 95 | .Dp Ar .ss |
| 96 | Seconds, a number from 0 to 60. |
| 97 | .Dp |
| 98 | .Pp |
| 99 | Everything but the minutes are optional. |
| 100 | .Pp |
| 101 | Time changes for Daylight Saving and Standard time and leap seconds |
| 102 | and years are handled automatically. |
| 103 | .Sh EXAMPLES |
| 104 | The command: |
| 105 | .Pp |
| 106 | .Dl date ``+DATE: %m/%d/%y%nTIME: %H:%M:n'' |
| 107 | .Pp |
| 108 | will display: |
| 109 | .Pp |
| 110 | .Dl DATE: 11/21/87 |
| 111 | .Dl TIME: 13:36:16 |
| 112 | .Pp |
| 113 | The command: |
| 114 | .Pp |
| 115 | .Dl date 8506131627 |
| 116 | .Pp |
| 117 | sets the date to June 13 1985, 4:27 PM. |
| 118 | .Pp |
| 119 | The command: |
| 120 | .Pp |
| 121 | .Dl date 1432 |
| 122 | .Pp |
| 123 | sets the time to 2:32 PM, without modifying the date. |
| 124 | .Sh FILES |
| 125 | .Dw /var/log/messages |
| 126 | .Di L |
| 127 | .Dp Pa /var/log/wtmp |
| 128 | A record of date resets and time changes. |
| 129 | .Dp Pa /var/log/messages |
| 130 | A record of the user setting the time. |
| 131 | .Sh SEE ALSO |
| 132 | .Xr gettimeofday 2 , |
| 133 | .Xr strftime 3 , |
| 134 | .Xr utmp 5 , |
| 135 | .Xr timed 8 |
| 136 | .br |
| 137 | .Em TSP:\ The\ Time\ Synchronization Protocol |
| 138 | .Em for UNIX 4.3BSD , |
| 139 | R. Gusella |
| 140 | and\ S.\ Zatti |
| 141 | .Sh HISTORY |
| 142 | .Nm Date |
| 143 | appeared in Version 6 AT&T UNIX. |
| 144 | .Sh DIAGNOSTICS |
| 145 | Exit status is 0 on success, 1 on if unable to set the date, and 2 on |
| 146 | if able to set the local date but failing to set it globally. |
| 147 | .Pp |
| 148 | Occasionally, when |
| 149 | .Xr timed |
| 150 | synchronizes the time on many hosts, the setting of a new time value may |
| 151 | require more than a few seconds. |
| 152 | On these occasions, |
| 153 | .Nm date |
| 154 | prints: `Network time being set'. |
| 155 | The message `Communication error with timed' occurs when the communication |
| 156 | between |
| 157 | .Nm date |
| 158 | and |
| 159 | .Xr timed |
| 160 | fails. |
| 161 | .Sh BUGS |
| 162 | The system attempts to keep the date in a format closely compatible |
| 163 | with VMS. |
| 164 | VMS, however, uses local time (rather than GMT) and does not understand |
| 165 | daylight-saving time. |
| 166 | Thus, if you use both UNIX and VMS, VMS will be running on GMT. |