logo

utils-std

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

date.1.in (2554B)


  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 d Ar datetime | Fl r Ar epoch
  14. .Op Cm + Ns Ar format
  15. .Nm
  16. .Op Fl jRu
  17. .Ar mmddHHMM Ns Oo Oo Ar CC Oc Ns Ar yy Oc
  18. .Op Cm + Ns Ar format
  19. .Nm
  20. .Op Fl jRu
  21. .Fl f Ar now_format
  22. .Ar now
  23. .Op Cm + Ns Ar format
  24. .Sh DESCRIPTION
  25. When
  26. .Nm
  27. is invoked without arguments it displays the current datetime
  28. Otherwise, depending on the options specified, will print the datetime in a user-defined way.
  29. .Sh OPTIONS
  30. .Bl -tag -width Ds
  31. .It Fl d Ar datetime
  32. Use
  33. .Ar datetime
  34. instead of current datetime.
  35. include(lib/iso_parse.mdoc)
  36. .It Fl f Ar now_format
  37. Use
  38. .Ar now_format
  39. as the
  40. .Xr strptime 3
  41. format string for
  42. .Ar now ,
  43. which will be used instead of the current datetime.
  44. .It Fl j
  45. Do no set the system date.
  46. This allows to use the
  47. .Fl f
  48. flag to convert one datetime to another.
  49. .It Fl u
  50. Use UTC (coordinated universal time) instead of the local time.
  51. .It Fl r Ar epoch
  52. Use
  53. .Ar epoch
  54. (seconds relative to 1970-01-01 00:00:00 UTC)
  55. instead of current datetime.
  56. .It Fl R
  57. Set the default value of
  58. .Ar format
  59. to match RFC5322 (Internet Message Format).
  60. .It Ar mmddHHMM Ns Oo Oo Ar CC Oc Ns Ar yy Oc
  61. Sets custom datetime, if
  62. .Fl j
  63. isn't set, the system time is also set.
  64. .Pp
  65. Each letters corresponds to:
  66. .Bl -tag -width mm -compact
  67. .It mm
  68. months aka %m
  69. .It dd
  70. days aka %d
  71. .It HH
  72. hours aka %H
  73. .It MM
  74. minutes aka %M
  75. .It CC
  76. centuries aka %C
  77. .It yy
  78. century-less years aka %y
  79. .El
  80. .Pp
  81. For example 072505542024 corresponds to 2024-07-25T05:54, as you can verify with the following command:
  82. .Dl date -j 072505542024 +%Y-%m-%dT%H:%M
  83. .It Cm + Ns Ar format
  84. Set the displayed datetime in
  85. .Xr strftime 3
  86. format.
  87. Otherwise defaults to
  88. .Ql %c
  89. .El
  90. .Sh ENVIRONMENT
  91. Look at the manual page of
  92. .Xr strftime 3
  93. for the environment variables, typical ones are
  94. .Ev TZ ,
  95. .Ev LC_TIME
  96. and
  97. .Ev LC_ALL
  98. but this depends on your system.
  99. .Sh EXIT STATUS
  100. .Ex -std
  101. .Sh SEE ALSO
  102. .Xr clock_settime 3 ,
  103. .Xr strftime 3
  104. .Sh STANDARDS
  105. .Nm
  106. should be compliant with the
  107. IEEE Std 1003.1-2024 (“POSIX.1”)
  108. specification.
  109. .Pp
  110. The
  111. .Fl d
  112. and
  113. .Fl R
  114. options are present for compatibility with other modern systems such as
  115. NetBSD, BusyBox, and GNU coreutils.
  116. .br
  117. The
  118. .Fl r
  119. option is inspired from BSD and illumos,
  120. .Fl f
  121. and
  122. .Fl j
  123. options are inspired by FreeBSD and NetBSD.
  124. .Sh AUTHORS
  125. .An Haelwenn (lanodan) Monnier Aq Mt contact+utils@hacktivis.me