logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git/

date.1.in (3244B)


  1. .\" utils-std: Collection of commonly available Unix tools
  2. .\" Copyright 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  3. .\" SPDX-License-Identifier: MPL-2.0
  4. .Dd 2024-07-25
  5. .Dt DATE 1
  6. .Os
  7. .Sh NAME
  8. .Nm date
  9. .Nd display date and time
  10. .Sh SYNOPSIS
  11. .Nm
  12. .Op Fl jRu
  13. .Op Fl I Ar iso_fmt
  14. .Op Fl d Ar datetime | Fl r Ar epoch
  15. .Op Cm + Ns Ar format
  16. .Nm
  17. .Op Fl jRu
  18. .Op Fl I Ar iso_fmt
  19. .Ar mmddHHMM Ns Oo Oo Ar CC Oc Ns Ar yy Oc
  20. .Op Cm + Ns Ar format
  21. .Nm
  22. .Op Fl jRu
  23. .Op Fl I Ar iso_fmt
  24. .Fl f Ar now_format
  25. .Ar now
  26. .Op Cm + Ns Ar format
  27. .Sh DESCRIPTION
  28. When
  29. .Nm
  30. is invoked without arguments it displays the current datetime
  31. Otherwise, depending on the options specified, will print the datetime in a user-defined way.
  32. .Sh OPTIONS
  33. .Bl -tag -width Ds
  34. .It Fl d Ar datetime
  35. Use
  36. .Ar datetime
  37. instead of current datetime.
  38. include(lib/iso_parse.mdoc)
  39. .It Fl f Ar now_format
  40. Use
  41. .Ar now_format
  42. as the
  43. .Xr strptime 3
  44. format string for
  45. .Ar now ,
  46. which will be used instead of the current datetime.
  47. .It Fl I Ar iso_fmt
  48. Set the ISO-8601 resolution to format at with setting
  49. .Ar iso_fmt
  50. to one of the following values:
  51. .Bl -tag -width m_inutes_
  52. .It Ar d Ns Op Ar ate
  53. date, equivalent to +%Y-%m-%d
  54. .It Ar h Ns Op Ar ours
  55. hours, equivalent to +%Y-%m-%dT%H%:z
  56. .It Ar m Ns Op Ar inutes
  57. minutes, equivalent to +%Y-%m-%dT%H:%M%:z
  58. .It Ar s Ns Op Ar econds
  59. seconds, equivalent to +%Y-%m-%dT%H:%M:%S%:z
  60. .It Ar n Ns Op Ar s
  61. nano-seconds, equivalent to +%Y-%m-%dT%H:%M:%S,%N%:z
  62. .El
  63. .It Fl j
  64. Do no set the system date.
  65. This allows to use the
  66. .Fl f
  67. flag to convert one datetime to another.
  68. .It Fl u
  69. Use UTC (coordinated universal time) instead of the local time.
  70. .It Fl r Ar epoch
  71. Use
  72. .Ar epoch
  73. (seconds relative to 1970-01-01 00:00:00 UTC)
  74. instead of current datetime.
  75. .It Fl R
  76. Set the default value of
  77. .Ar format
  78. to match RFC5322 (Internet Message Format).
  79. .It Ar mmddHHMM Ns Oo Oo Ar CC Oc Ns Ar yy Oc
  80. Sets custom datetime, if
  81. .Fl j
  82. isn't set, the system time is also set.
  83. .Pp
  84. Each letters corresponds to:
  85. .Bl -tag -width mm -compact
  86. .It mm
  87. months aka %m
  88. .It dd
  89. days aka %d
  90. .It HH
  91. hours aka %H
  92. .It MM
  93. minutes aka %M
  94. .It CC
  95. centuries aka %C
  96. .It yy
  97. century-less years aka %y
  98. .El
  99. .Pp
  100. For example 072505542024 corresponds to 2024-07-25T05:54, as you can verify with the following command:
  101. .Dl date -j 072505542024 +%Y-%m-%dT%H:%M
  102. .It Cm + Ns Ar format
  103. Set the displayed datetime in
  104. .Xr strftime 3
  105. format,
  106. with additionally
  107. %N for nanoseconds and %:z for colon-separated timezone (±ZZ:ZZ).
  108. .br
  109. Otherwise defaults to
  110. .Ql %c
  111. .El
  112. .Sh ENVIRONMENT
  113. Look at the manual page of
  114. .Xr strftime 3
  115. for the environment variables, typical ones are
  116. .Ev TZ ,
  117. .Ev LC_TIME
  118. and
  119. .Ev LC_ALL
  120. but this depends on your system.
  121. .Sh EXIT STATUS
  122. .Ex -std
  123. .Sh SEE ALSO
  124. .Xr clock_settime 3 ,
  125. .Xr strftime 3
  126. .Sh STANDARDS
  127. .Nm
  128. should be compliant with the
  129. IEEE Std 1003.1-2024 (“POSIX.1”)
  130. specification.
  131. .Pp
  132. The
  133. .Fl d
  134. and
  135. .Fl R
  136. options are present for compatibility with other modern systems such as
  137. NetBSD, BusyBox, and GNU coreutils.
  138. .br
  139. The
  140. .Fl r
  141. option is inspired from BSD and illumos,
  142. .Fl f
  143. and
  144. .Fl j
  145. options are inspired by FreeBSD and NetBSD.
  146. .Pp
  147. The %N and %:z formats are extensions inspired from GNU coreutils.
  148. .Sh AUTHORS
  149. .An Haelwenn (lanodan) Monnier Aq Mt contact+utils@hacktivis.me