date (target)
Display or set the date and time (POSIX, toybox)
Syntax:
date [-u] [-I res] [-r file] [-d date] [+display_format] [-D set_format] [set]
Runs on:
QNX OS
Options:
- -D set_format
- The +format specified for set or -d (instead of MMDDhhmm[[CC]YY][.ss]).
- -d date
- Show the date instead of the current time (convert the date format.)
- -I res
- Output the date and time in ISO 8601 format with the specified resolution. The following
values are valid for res:
- d — date
- h — hours
- m — minutes
- n — nanoseconds
- s — seconds
- -r file
- Use the modification time of file instead of the current date.
- -s date
- Set the system clock to the specified date.
- -u
- Give time in universal coordinated time (UTC) instead of current timezone.
- +display_format
- The format to display the date and time in.
- set
- Sets the date and time.
Description:
The date utility is used to display and set the current system date and time in software. With no set, the date utility shows the current date.
The date utilitiy recognizes the following formats:
- MMDDhhmm [[CC]YY][.SS]
- YYYY-MM-DD [hh:mm[:ss]]
- hh:mm[:ss]
- @UNIXTIME[.FRACTION]
- CC
- Century (e.g., 19 if the year is 1997).
- YY
- Year modulo 100 (e.g., 97 if the year is 1997). When the century is not specified (with CC), the years 69-99 are 1969 to 1999, and 00-68 are 2000 to 2068.
- MM
- Numerical month of the year (01 for January 02 for February, etc.)
- DD
- Day of the month.
- hh
- Hour of the day.
- mm
- Minute of the hour.
- SS
- Seconds of the minute.
The @UNIXTIME[.FRACTION] format expresses the number of seconds that have passed since January 1, 1970 at 00:00:00 (midnight).
The +format operand specifies the display format strings using strtime() syntax. The following field descriptors are supported:
%%
- A literal %.
%A
- Locale's weekday name (e.g., Sunday).
%a
- Locale's shortened weekday name (e.g., Sun).
%B
- Locale's month name (e.g., January).
%b
- Locale's shortened month name (e.g., Jan).
%C
- Century.
%c
- Locale's date and time.
%D
- Date; same as %m/%d/%y.
%d
- Day of the month (e.g., 01-31).
%e
- Day of month (e.g., 1-31).
%F
- Full date; same as %y-%m-%d.
%H
- Hour (0-23).
%h
- Same as %b.
%I
- Hour (01-12).
%j
- Day of the year (001-366).
%M
- Minute (00-59).
%m
- Month (01-12).
%N
- Nanoseconds (output only).
%n
- A newline.
%p
- Locale's equivalent of AM or PM.
%R
- 24-hour hour and minute; same as %H:%M.
%r
- Locale's 12-hour clock time; same as %I:%M:%S %p (e.g., 11:11:04 PM).
%S
- Seconds (00-60).
%s
- Unix Epoch time.
%T
- Time; same as %H:%M:%S.
%t
- A tab character.
%U
- Week number of the year, with Sunday as the first day of week (0-53).
%u
- Day of the week (1-7, where 1 is Monday).
%V
- Week number of the year, with Monday as the first day of week (1-53). Weeks with less than 4 days are not part of this year.
%W
- Week number of the year, with Monday as the first day of the week (0-53).
%X
- Locale's time.
%x
- Locale's date.
%Y
- Year.
%y
- Short year (00-99).
%Z
- Timezone name.
%z
- Timezone (-0800).
%:z
- Timezone (-08:00).
This utility is provided as part of the toybox package. For information on how to enable it, see toybox.
Environment Variables:
- TZ
- Specifies the local timezone for the specified timezone.
Contributing author:
Rob Landley and the toybox project (see https://landley.net/toybox/).