1.\"- 2.\" Copyright (c) 1980, 1990, 1993 3.\" The Regents of the University of California. All rights reserved. 4.\" 5.\" This code is derived from software contributed to Berkeley by 6.\" the Institute of Electrical and Electronics Engineers, Inc. 7.\" 8.\" Redistribution and use in source and binary forms, with or without 9.\" modification, are permitted provided that the following conditions 10.\" are met: 11.\" 1. Redistributions of source code must retain the above copyright 12.\" notice, this list of conditions and the following disclaimer. 13.\" 2. Redistributions in binary form must reproduce the above copyright 14.\" notice, this list of conditions and the following disclaimer in the 15.\" documentation and/or other materials provided with the distribution. 16.\" 3. Neither the name of the University nor the names of its contributors 17.\" may be used to endorse or promote products derived from this software 18.\" without specific prior written permission. 19.\" 20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" SUCH DAMAGE. 31.\" 32.Dd November 5, 2025 33.Dt DATE 1 34.Os 35.Sh NAME 36.Nm date 37.Nd display or set date and time 38.Sh SYNOPSIS 39.\" Display time. 40.Nm 41.Op Fl nRu 42.Op Fl z Ar output_zone 43.Op Fl I Ns Op Ar FMT 44.Op Fl r Ar filename 45.Op Fl r Ar seconds 46.Oo 47.Sm off 48.Fl v 49.Op Cm + | - 50.Ar val Op Cm y | m | w | d | H | M | S 51.Sm on 52.Oc 53.Op Cm + Ns Ar output_fmt 54.\" Set time with the default input format. 55.Nm 56.Op Fl jnRu 57.Op Fl z Ar output_zone 58.Op Fl I Ns Op Ar FMT 59.Oo 60.Sm off 61.Fl v 62.Op Cm + | - 63.Ar val Op Cm y | m | w | d | H | M | S 64.Sm on 65.Oc 66.Sm off 67.Oo Oo Oo Oo Oo 68.Ar cc Oc 69.Ar yy Oc 70.Ar mm Oc 71.Ar dd Oc 72.Ar HH 73.Oc Ar MM Op Cm \&. Ar SS 74.Sm on 75.Op Cm + Ns Ar output_fmt 76.\" Set time with the user-provided input format. 77.Nm 78.Op Fl jnRu 79.Op Fl z Ar output_zone 80.Op Fl I Ns Op Ar FMT 81.Oo 82.Sm off 83.Fl v 84.Op Cm + | - 85.Ar val Op Cm y | m | w | d | H | M | S 86.Sm on 87.Oc 88.Fl f Ar input_fmt 89.Ar new_date 90.Op Cm + Ns Ar output_fmt 91.Sh DESCRIPTION 92When invoked without arguments, the 93.Nm 94utility displays the current date and time. 95Otherwise, depending on the options specified, 96.Nm 97will set the date and time or print it in a user-defined way. 98.Pp 99The 100.Nm 101utility displays the date and time read from the kernel clock. 102When used to set the date and time, 103both the kernel clock and the hardware clock are updated. 104.Pp 105Only the superuser may set the date, 106and if the system securelevel (see 107.Xr securelevel 7 ) 108is greater than 1, 109the time may not be changed by more than 1 second. 110.Pp 111The options are as follows: 112.Bl -tag -width Ds 113.It Fl f Ar input_fmt 114Use 115.Ar input_fmt 116as the format string to parse the 117.Ar new_date 118provided rather than using the default 119.Sm off 120.Oo Oo Oo Oo Oo 121.Ar cc Oc 122.Ar yy Oc 123.Ar mm Oc 124.Ar dd Oc 125.Ar HH 126.Oc Ar MM Op Cm \&. Ar SS 127.Sm on 128format. 129Parsing is done using 130.Xr strptime 3 . 131.It Fl I Ns Op Ar FMT 132Use extended 133.St -iso8601 134output format. 135.Ar FMT 136may be omitted, in which case the default is 137.Cm date . 138Valid 139.Ar FMT 140values are 141.Cm date , 142.Cm hours , 143.Cm minutes , 144.Cm seconds , 145and 146.Cm ns 147.Pq for nanoseconds . 148The date and time is formatted to the specified precision. 149When 150.Ar FMT 151is 152.Cm hours 153.Po or the more precise 154.Cm minutes , 155.Cm seconds , 156or 157.Cm ns Pc , 158the extended 159.St -iso8601 160format includes the timezone offset. 161.It Fl j 162Do not try to set the date. 163This allows you to use the 164.Fl f 165flag in addition to the 166.Cm + 167option to convert one date format to another. 168Note that any date or time components unspecified by the 169.Fl f 170format string take their values from the current time. 171.It Fl n 172Obsolete flag, accepted and ignored for compatibility. 173.It Fl R 174Use RFC 2822 date and time output format. 175This is equivalent to using 176.Ql %a, %d %b %Y \&%T %z 177as 178.Ar output_fmt 179while 180.Ev LC_TIME 181is set to the 182.Dq C 183locale . 184.It Fl r Ar seconds 185Print the date and time represented by 186.Ar seconds , 187where 188.Ar seconds 189is the number of seconds since the Epoch 190(00:00:00 UTC, January 1, 1970; 191see 192.Xr time 3 ) , 193and can be specified in decimal, octal, or hex. 194.It Fl r Ar filename 195Print the date and time of the last modification of 196.Ar filename . 197.It Fl u 198Display or set the date in UTC (Coordinated Universal) time. 199By default 200.Nm 201displays the time in the time zone described by 202.Pa /etc/localtime 203or the 204.Ev TZ 205environment variable. 206.It Fl z Ar output_zone 207Just before printing the time, change to the specified timezone; 208see the description of 209.Ev TZ 210below. 211This can be used with 212.Fl j 213to easily convert time specifications from one zone to another. 214.It Xo 215.Fl v 216.Sm off 217.Op Cm + | - 218.Ar val Op Cm y | m | w | d | H | M | S 219.Sm on 220.Xc 221Adjust (i.e., take the current date and display the result of the 222adjustment; not actually set the date) the second, minute, hour, month 223day, week day, month or year according to 224.Ar val . 225If 226.Ar val 227is preceded by a plus or minus sign, 228the date is adjusted forward or backward according to the remaining string, 229otherwise the relevant part of the date is set. 230The date can be adjusted as many times as required using these flags. 231Flags are processed in the order given. 232.Pp 233When setting values 234(rather than adjusting them), 235seconds are in the range 0-59, minutes are in the range 0-59, hours are 236in the range 0-23, month days are in the range 1-31, week days are in the 237range 0-6 (Sun-Sat), 238months are in the range 1-12 (Jan-Dec) 239and years are in a limited range depending on the platform. 240.Pp 241On i386, years are in the range 69-38 representing 1969-2038. 242On every other platform, years 0-68 are accepted and represent 2000-2068, and 24369-99 are accepted and represent 1969-1999. 244In both cases, years between 100 and 1900 (both included) are accepted and 245interpreted as relative to 1900 of the Gregorian calendar with a limit of 138 on 246i386 and a much higher limit on every other platform. 247Years starting at 1901 are also accepted, and are interpreted as absolute years. 248.Pp 249If 250.Ar val 251is numeric, one of either 252.Cm y , 253.Cm m , 254.Cm w , 255.Cm d , 256.Cm H , 257.Cm M 258or 259.Cm S 260must be used to specify which part of the date is to be adjusted. 261.Pp 262The week day or month may be specified using a name rather than a 263number. 264If a name is used with the plus 265(or minus) 266sign, the date will be put forwards 267(or backwards) 268to the next 269(previous) 270date that matches the given week day or month. 271This will not adjust the date, 272if the given week day or month is the same as the current one. 273.Pp 274When a date is adjusted to a specific value or in units greater than hours, 275daylight savings time considerations are ignored. 276Adjustments in units of hours or less honor daylight saving time. 277So, assuming the current date is March 26, 0:30 and that the DST adjustment 278means that the clock goes forward at 01:00 to 02:00, using 279.Fl v No +1H 280will adjust the date to March 26, 2:30. 281Likewise, if the date is October 29, 0:30 and the DST adjustment means that 282the clock goes back at 02:00 to 01:00, using 283.Fl v No +3H 284will be necessary to reach October 29, 2:30. 285.Pp 286When the date is adjusted to a specific value that does not actually exist 287(for example March 26, 1:30 BST 2000 in the Europe/London timezone), 288the date will be silently adjusted forward in units of one hour until it 289reaches a valid time. 290When the date is adjusted to a specific value that occurs twice 291(for example October 29, 1:30 2000), 292the resulting timezone will be set so that the date matches the earlier of 293the two times. 294.Pp 295It is not possible to adjust a date to an invalid absolute day, so using 296the switches 297.Fl v No 31d Fl v No 12m 298will simply fail five months of the year. 299It is therefore usual to set the month before setting the day; using 300.Fl v No 12m Fl v No 31d 301always works. 302.Pp 303Adjusting the date by months is inherently ambiguous because 304a month is a unit of variable length depending on the current date. 305This kind of date adjustment is applied in the most intuitive way. 306First of all, 307.Nm 308tries to preserve the day of the month. 309If it is impossible because the target month is shorter than the present one, 310the last day of the target month will be the result. 311For example, using 312.Fl v No +1m 313on May 31 will adjust the date to June 30, while using the same option 314on January 30 will result in the date adjusted to the last day of February. 315This approach is also believed to make the most sense for shell scripting. 316Nevertheless, be aware that going forth and back by the same number of 317months may take you to a different date. 318.Pp 319Refer to the examples below for further details. 320.El 321.Pp 322An operand with a leading plus 323.Pq Sq + 324sign signals a user-defined format string 325which specifies the format in which to display the date and time. 326The format string may contain any of the conversion specifications 327described in the 328.Xr strftime 3 329manual page and 330.Ql \&%N 331for nanoseconds, as well as any arbitrary text. 332A newline 333.Pq Ql \en 334character is always output after the characters specified by 335the format string. 336The format string for the default display is 337.Dq +%+ . 338.Pp 339If an operand does not have a leading plus sign, it is interpreted as 340a value for setting the system's notion of the current date and time. 341The canonical representation for setting the date and time is: 342.Pp 343.Bl -tag -width Ds -compact -offset indent 344.It Ar cc 345Century 346(either 19 or 20) 347prepended to the abbreviated year. 348.It Ar yy 349Year in abbreviated form 350(e.g., 89 for 1989, 06 for 2006). 351.It Ar mm 352Numeric month, a number from 1 to 12. 353.It Ar dd 354Day, a number from 1 to 31. 355.It Ar HH 356Hour, a number from 0 to 23. 357.It Ar MM 358Minutes, a number from 0 to 59. 359.It Ar SS 360Seconds, a number from 0 to 60 361(59 plus a potential leap second). 362.El 363.Pp 364Everything but the minutes is optional. 365.Pp 366.Nm 367understands the time zone definitions from the IANA Time Zone Database, 368.Sy tzdata , 369located in 370.Pa /usr/share/zoneinfo . 371Time changes for Daylight Saving Time, standard time, leap seconds 372and leap years are handled automatically. 373.Pp 374There are two ways to specify the time zone: 375.Pp 376If the file or symlink 377.Pa /etc/localtime 378exists, it is interpreted as a time zone definition file, usually in 379the directory hierarchy 380.Pa /usr/share/zoneinfo , 381which contains the time zone definitions from 382.Sy tzdata . 383.Pp 384If the environment variable 385.Ev TZ 386is set, its value is interpreted as the name of a time zone definition 387file, either an absolute path or a relative path to a time zone 388definition in 389.Pa /usr/share/zoneinfo . 390The 391.Ev TZ 392variable overrides 393.Pa /etc/localtime . 394.Pp 395If the time zone definition file is invalid, 396.Nm 397silently reverts to UTC. 398.Pp 399Previous versions of 400.Nm 401included the 402.Fl d 403(set daylight saving time flag) and 404.Fl t 405(set negative time zone offset) options, but these details are now 406handled automatically by 407.Sy tzdata . 408Modern offsets are positive for time zones ahead of UTC and negative 409for time zones behind UTC, but like the obsolete 410.Fl t 411option, the 412.Sy tzdata 413files in the subdirectory 414.Pa /usr/share/zoneinfo/Etc 415still use an older convention where times ahead of UTC are considered 416negative. 417.Sh ENVIRONMENT 418The following environment variable affects the execution of 419.Nm : 420.Bl -tag -width Ds 421.It Ev TZ 422The timezone to use when displaying dates. 423The normal format is a pathname relative to 424.Pa /usr/share/zoneinfo . 425For example, the command 426.Dq TZ=America/Los_Angeles date 427displays the current time in California. 428The variable can also specify an absolute path. 429See 430.Xr environ 7 431for more information. 432.El 433.Sh FILES 434.Bl -tag -width /var/log/messages -compact 435.It Pa /etc/localtime 436Time zone information file for default system time zone. 437May be omitted, in which case the default time zone is UTC. 438.It Pa /usr/share/zoneinfo 439Directory containing time zone information files. 440.It Pa /var/log/messages 441Record of the user setting the time. 442.It Pa /var/log/utx.log 443Record of date resets and time changes. 444.El 445.Sh EXIT STATUS 446The 447.Nm 448utility exits 0 on success, 1 if unable to set the date, and 2 449if able to set the local date, but unable to set it globally. 450.Sh EXAMPLES 451The command: 452.Pp 453.Dl "date ""+DATE: %Y-%m-%d%nTIME: %H:%M:%S""" 454.Pp 455will display: 456.Bd -literal -offset indent 457DATE: 1987-11-21 458TIME: 13:36:16 459.Ed 460.Pp 461In the Europe/London timezone, the command: 462.Pp 463.Dl "date -v1m -v+1y" 464.Pp 465will display: 466.Pp 467.Dl "Sun Jan 4 04:15:24 GMT 1998" 468.Pp 469where it is currently 470.Ql "Mon Aug 4 04:15:24 BST 1997" . 471.Pp 472The command: 473.Pp 474.Dl "date -v1d -v3m -v0y -v-1d" 475.Pp 476will display the last day of February in the year 2000: 477.Pp 478.Dl "Tue Feb 29 03:18:00 GMT 2000" 479.Pp 480So will the command: 481.Pp 482.Dl "date -v3m -v30d -v0y -v-1m" 483.Pp 484because there is no such date as the 30th of February. 485.Pp 486The command: 487.Pp 488.Dl "date -v1d -v+1m -v-1d -v-fri" 489.Pp 490will display the last Friday of the month: 491.Pp 492.Dl "Fri Aug 29 04:31:11 BST 1997" 493.Pp 494where it is currently 495.Ql "Mon Aug 4 04:31:11 BST 1997" . 496.Pp 497The command: 498.Pp 499.Dl "date 8506131627" 500.Pp 501sets the date to 502.Ql "June 13, 1985, 4:27 PM" . 503.Pp 504.Dl "date ""+%Y%m%d%H%M.%S""" 505.Pp 506may be used on one machine to print out the date 507suitable for setting on another. 508.Po Use 509.Ql "+%m%d%H%M%Y.%S" 510with GNU date on 511Linux . 512.Pc 513.Pp 514The command: 515.Pp 516.Dl "date 1432" 517.Pp 518sets the time to 519.Ql "2:32 PM" , 520without modifying the date. 521.Pp 522The command 523.Pp 524.Dl "TZ=America/Los_Angeles date -Iseconds -r 1533415339" 525.Pp 526will display 527.Pp 528.Dl "2018-08-04T13:42:19-07:00" 529.Pp 530The command: 531.Pp 532.Dl "env LC_ALL=C date -j -f ""%a %b %d %T %Z %Y"" ""`env LC_ALL=C date`"" ""+%s""" 533.Pp 534can be used to parse the output from 535.Nm 536and express it in Epoch time. 537.Pp 538Finally the command 539.Pp 540.Dl "TZ=America/Los_Angeles date -z Europe/Paris -j 0900" 541.Pp 542will print the time in the 543.Dq Europe/Paris 544timezone when it is 9:00 in the 545.Dq America/Los_Angeles 546timezone. 547.Sh DIAGNOSTICS 548It is invalid to combine the 549.Fl I 550flag with either 551.Fl R 552or an output format 553.Dq ( + Ns ... ) 554operand. 555If this occurs, 556.Nm 557prints: 558.Ql multiple output formats specified 559and exits with status 1. 560.Sh SEE ALSO 561.Xr locale 1 , 562.Xr clock_gettime 2 , 563.Xr gettimeofday 2 , 564.Xr getutxent 3 , 565.Xr strftime 3 , 566.Xr strptime 3 , 567.Xr tzset 3 , 568.Xr adjkerntz 8 , 569.Xr ntpd 8 , 570.Xr tzsetup 8 571.Rs 572.%T "TSP: The Time Synchronization Protocol for UNIX 4.3BSD" 573.%A R. Gusella 574.%A S. Zatti 575.Re 576.Rs 577.%U https://iana.org/time-zones 578.%T Time Zone Database 579.Re 580.Sh STANDARDS 581The 582.Nm 583utility is expected to be compatible with 584.St -p1003.2 . 585With the exception of the 586.Fl u 587option, all options are extensions to the standard. 588.Pp 589The format selected by the 590.Fl I 591flag is compatible with 592.St -iso8601 . 593.Pp 594The 595.Ql \&%N 596conversion specification for nanoseconds is a non-standard extension. 597It is compatible with GNU date's 598.Ql \&%N . 599.Sh HISTORY 600A 601.Nm 602command appeared in 603.At v1 . 604.Pp 605A number of options were added and then removed again, including the 606.Fl d 607(set DST flag) and 608.Fl t 609(set negative time zone offset). 610Time zones are now handled by code bundled with 611.Sy tzdata . 612.Pp 613The 614.Fl I 615flag was added in 616.Fx 12.0 . 617.Pp 618The 619.Ql \&%N 620conversion specification was added in 621.Fx 14.1 . 622