logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

date.1 (4915B)


  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 April 6, 2025
  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 time
  31. Otherwise, depending on the options specified,
  32. will print the datetime in a user-defined way.
  33. .Sh OPTIONS
  34. .Bl -tag -width Ds
  35. .It Fl d Ar datetime
  36. Use
  37. .Ar datetime
  38. instead of current time, see
  39. .Sx DATETIME FORMAT
  40. section for more details.
  41. .It Fl f Ar now_format
  42. Use
  43. .Ar now_format
  44. as the
  45. .Xr strptime 3
  46. format string for
  47. .Ar now ,
  48. which will be used instead of the current time.
  49. .It Fl I Ar iso_fmt
  50. Set the ISO-8601 resolution to format at with setting
  51. .Ar iso_fmt
  52. to one of the following values:
  53. .Bl -tag -width m_inutes_
  54. .It Ar d Ns Op Ar ate
  55. date, equivalent to +%Y-%m-%d
  56. .It Ar h Ns Op Ar ours
  57. hours, equivalent to +%Y-%m-%dT%H%:z
  58. .It Ar m Ns Op Ar inutes
  59. minutes, equivalent to +%Y-%m-%dT%H:%M%:z
  60. .It Ar s Ns Op Ar econds
  61. seconds, equivalent to +%Y-%m-%dT%H:%M:%S%:z
  62. .It Ar n Ns Op Ar s
  63. nano-seconds, equivalent to +%Y-%m-%dT%H:%M:%S,%N%:z
  64. .El
  65. .It Fl j
  66. Do no set the system date.
  67. This allows to use the
  68. .Fl f
  69. flag to convert one datetime to another.
  70. .It Fl u
  71. Use UTC (coordinated universal time) instead of the local time.
  72. .It Fl r Ar epoch
  73. Use
  74. .Ar epoch
  75. (seconds relative to 1970-01-01 00:00:00 UTC)
  76. instead of current time.
  77. .It Fl R
  78. Set the default value of
  79. .Ar format
  80. to match RFC5322 (Email / Internet Message Format).
  81. .It Ar mmddHHMM Ns Oo Oo Ar CC Oc Ns Ar yy Oc
  82. Sets custom datetime, if
  83. .Fl j
  84. isn't set, the system time is also set.
  85. .Pp
  86. Each letters corresponds to:
  87. .Bl -tag -width mm -compact
  88. .It mm
  89. months aka %m
  90. .It dd
  91. days aka %d
  92. .It HH
  93. hours aka %H
  94. .It MM
  95. minutes aka %M
  96. .It CC
  97. centuries aka %C
  98. .It yy
  99. century-less years aka %y
  100. .El
  101. .Pp
  102. For example 072505542024 corresponds to 2024-07-25T05:54,
  103. as you can verify with the following command:
  104. .Dl date -j 072505542024 +%Y-%m-%dT%H:%M
  105. .It Cm + Ns Ar format
  106. Set the displayed datetime in
  107. .Xr strftime 3
  108. format,
  109. with additionally
  110. %N for nanoseconds and %:z for colon-separated timezone (±ZZ:ZZ).
  111. .br
  112. Otherwise defaults to
  113. .Ql %c
  114. .El
  115. .Sh DATETIME FORMAT
  116. .\" utils-std: Collection of commonly available Unix tools
  117. .\" Copyright 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  118. .\" SPDX-License-Identifier: MPL-2.0
  119. .\"
  120. Multiple different but unambiguous formats are supported:
  121. @epoch, Email, asctime, RFC3339.
  122. .Ss @epoch
  123. Leading @ (at) symbol followed by
  124. the Unix timestamp (number of seconds before and after 1970-01-01 00:00:00Z),
  125. for example
  126. .Ql @1698791420
  127. corresponds to 2023-10-31 23:30:20 UTC
  128. .Ss Email
  129. Also known as "Internet Message Format" (RFC5322, RFC2822, RFC822), for example:
  130. .Bl -bullet -compact
  131. .It
  132. .Ql Fri, 21 Nov 1997 09:55:06 -0600
  133. .It
  134. .Ql 21 Nov 97 09:55:06 GMT
  135. .El
  136. .Ss asctime
  137. Output format of
  138. .Xr asctime 3 ,
  139. for example:
  140. .Ql Sun Sep 16 01:03:52 1973
  141. .Ss RFC3339
  142. Profile of ISO\ 8601:1988, found in modern protocols and file formats.
  143. Formatted as
  144. .Ql YYYY-MM-DDThh:mm:SS[frac][tz] ,
  145. where:
  146. .Bl -tag -width Ds
  147. .It Ql YYYY-MM-DD
  148. Corresponds to %Y-%m-%d of
  149. .Xr strptime 3 .
  150. .It Ql T
  151. Is either
  152. .Ql T
  153. or a space.
  154. .It Ql [frac]
  155. Is either empty, or fractional seconds starting with either a comma
  156. .Pq \&,
  157. or a period
  158. .Pq \&. .
  159. .It Ql [tz]
  160. When empty it corresponds to local time.
  161. Otherwise it can be an UTC offset in the format
  162. .Ql [+-]HH:?MM
  163. or the letter
  164. .Qq Z ,
  165. signifying UTC.
  166. .El
  167. .Pp
  168. Some examples:
  169. .Bl -bullet -compact
  170. .It
  171. .Ql 2003-06-02T13:37:42.713Z
  172. .It
  173. .Ql 1971-01-02T03:04:05.678+0900
  174. .El
  175. .Sh ENVIRONMENT
  176. Look at the manual page of
  177. .Xr strftime 3
  178. for the environment variables, typical ones are
  179. .Ev TZ ,
  180. .Ev LC_TIME
  181. and
  182. .Ev LC_ALL
  183. but this depends on your system.
  184. .Sh EXIT STATUS
  185. .Ex -std
  186. .Sh SEE ALSO
  187. .Xr clock_settime 3 ,
  188. .Xr strftime 3
  189. .Sh STANDARDS
  190. .Nm
  191. should be compliant with the
  192. IEEE Std 1003.1-2024 (“POSIX.1”)
  193. specification.
  194. .Pp
  195. The
  196. .Fl d
  197. and
  198. .Fl R
  199. options are present for compatibility with other modern systems such as
  200. NetBSD, BusyBox, and GNU coreutils.
  201. .br
  202. The
  203. .Fl r
  204. option is inspired from BSD and illumos,
  205. .Fl f
  206. and
  207. .Fl j
  208. options are inspired by FreeBSD and NetBSD.
  209. .Pp
  210. The %N and %:z formats are extensions inspired from GNU coreutils.
  211. .Pp
  212. The
  213. .Fl I
  214. option was added for compatibility with GNU coreutils, BusyBox, FreeBSD 12.0+.
  215. .Sh HISTORY
  216. The
  217. .Fl R ,
  218. .Fl d ,
  219. .Fl f ,
  220. .Fl j ,
  221. and
  222. .Fl r
  223. options were present in utils-std 0.0.1.
  224. The
  225. .Fl I
  226. option and %N and %:z formats were added in utils-std 0.0.2.
  227. .Sh AUTHORS
  228. .An Haelwenn (lanodan) Monnier Aq Mt contact+utils@hacktivis.me