Shell Commands/Date

From MorphOS Library

Revision as of 13:28, 3 February 2026 by JPV (talk | contribs) (Added the LFORMAT option)

< Shell Commands

Date - Displays or sets the date and time of the system

DAY, DATE, TIME, TO=VER/K

DAY     - sets the day to DAY                                                  
DATE    - sets the date to DATE
TIME    - sets the time to TIME
TO      - sets the date to that of the TO file
LFORMAT - defines a string to specially format the output

Date with no argument displays the currently set system time and date, including the day of the week. Time is displayed using a 24-hour clock.

Date DATE sets only the date. The format for entry and display of DATE is DD-MMM-YY (day-month-year). The hyphens between the arguments are required. A leading zero in the date is not necessary. The number or the first three letters of the month (in English) must be used, as well as the last two digits of the year.

The LFORMAT option modifies the output of Date. The available substitution operators are:

%a - Abbreviated weekday name
%A - Weekday name
%b - Abbreviated month name
%B - Month name
%c - The same as "%a %b %d %H:%M:%S %Y"
%C - The same as "%a %b %e %T %Y"
%d - Day number with leading zeros
%D - The same as "%m/%d/%y"
%e - Day number with leading spaces
%F - The same as "%Y-%m-%d"
%h - Abbreviated month name
%H - Hour using 24 hour style with leading zeros
%I - Hour using 12 hour style with leading zeros
%j - Julian date
%m - Month number with leading zeros
%M - The number of minutes with leading zeros
%n - Linefeed
%p - AM or PM string
%P - am or pm string
%q - Hour using 24 hour style
%Q - Hour using 12 hour style
%r - The same as "%I:%M:%S %p"
%R - The same as "%H:%M"
%S - The number of seconds with leading zeros
%t - Tab
%T - The same as "%H:%M:%S"
%U - The week number, taking Sunday as the first day of the week
%w - The weekday number
%W - The week number, taking Monday as the first day of the week
%x - The same as "%m/%d/%y"
%X - The same as "%H:%M:%S"
%y - The year using two digits with leading zeros
%Y - The year using four digits with leading zeros

Example:

Ram Disk:> Date LFORMAT="Today is %A."
Today is Tuesday.