Home Page The Club Computers News Links Glossary EYAWTK
Before Amiga Background ICS OCS ECS AGA ??? PPC
U-Boot SLB Linux Amiga OS Dual Boot Motherboards Peripherals Other
Initialisation Installation OS4 Updates About OS4 File Systems Networking Printing Other
Introduction File System Workbench Preferences Commands Error Msgs Miscellaneous

AmigaOS 4.0 - About OS4 - Commands

Purpose: To display or set the system date and/or time.
Format: DATE [<day>] [<date>] [<time>] [SERVER <name>] [PORT <n>] [OFFSET <n>] [LFORMAT <string>] [TO | VER <filename>]
Path: C:DATE
DATE with no argument displays the currently set system date and time, including the day of the week. Time is displayed using a 24-hour clock.

DATE <date> sets just the date. The date can be specified either in the current default locale format or in the AmigaDOS format DD-MMM-YY (day-month-year). If the AmigaDOS format is used, the hyphens between the arguments are required. A leading zero in the date is not necessary. The first 3 letters of the month (in the current locale language) must be used, as well as the last two digits of the year.

The date can also be reset by specifying a day name, thus setting the date forward to that day of the week. You can also use tomorrow or yesterday as the <day> argument.

DATE <time> sets the time. The time can be specified either in the current default locale format or in the AmigaDOS format HH:MM:SS (hours:minutes:seconds). Seconds are optional.

The SERVER option is used to retrieve the current date and time from a remote server over a TCP/IP connection using the Network Time Protocol (NTP). A list of NTP time servers and some good background information can be found at http://ntp.isc.org/bin/view/Servers/WebHome.

By using PORT you can specify a port number different to the default 123.

The OFFSET argument allows to set the offset in minutes of your location with respect to Greenwich Mean Time (GMT). If OFFSET is not specified, the locale offset will be used.

The LFORMAT option modifies the output of DATE using one or more substitution operators. The available substitution operators are:

%a - abbreviated weekday name
%A - weekday name
%b - abbreviated month name
%B - month name
%c - same as "%a %b %d %H:%M:%S %Y"
%d - day number with leading 0s
%D - same as "%m/%d/%y"
%e - day number with leading spaces
%h - abbreviated month name
%H - hour using 24-hour style with leading 0s
%I - hour using 12-hour style with leading 0s
%j - julian date
%m - month number with leading 0s
%M - the number of minutes with leading 0s
%n - insert a linefeed
%p - AM or PM strings
%q - hour using 24-hour style
%Q - hour using 12-hour style
%r - same as "%I:%M:%S %p"
%R - same as "%H:%M"
%S - number of seconds with leadings 0s
%t - insert a tab character
%T - same as "%H:%M:%S"
%U - week number, taking Sunday as first day of week
%w - weekday number
%W - week number, taking Monday as first day of week
%x - same as "%m/%d/%y"
%X - same as "%H:%M:%S"
%y - year using two digits with leading 0s
%Y - year using four digits with leading 0s
If you specify the TO or VER option, followed by a filename, the output of the DATE command is sent to that file, overwriting any existing contents.

If your Amiga does not have a battery backed-up hardware clock and you do not set the date, the system, upon booting, will set the date to the date of the most recently created file on the boot disk.

NOTE: Adjustments made with DATE only change the software clock. They will not survive past power-down. To set the battery backed-up hardware clock from the Shell, you must set the date and use SETCLOCK SAVE.

If DATE succeeded in setting the system date and/or time the primary return code (RC) will be set to 0. A return code of 5 or 20 indicates that DATE failed partially or completely. If an error occurred when trying to get time from a remote server the primary return code will be set to 21. In this case the secondary return code (RESULT2) may contain a tcp stack socket/resolver error number and the corresponding error message will be displayed.

Example 1:

3.OS4:> DATE displays the current date and time.

Example 2:

3.OS4:> DATE LFORMAT "Today it's %A, %m/%d/%Y, %T" displays a message like "Today it's Monday, 02/17/2003, 22:30:56".

Example 3:

3.OS4:> DATE 1-jan-05 sets the date to January 1st, 2005 (the earliest date you can set is January 1, 1978). The time is not reset.

Example 4:

3.OS4:> DATE tomorrow resets the date to one day ahead.

Example 5:

3.OS4:> DATE TO Fred sends the current date to the file Fred.

Example 6:

3.OS4:> DATE 23:00 sets the current time to 11:00 p.m..

Example 7:

3.OS4:> DATE SERVER foo.bar.com OFFSET -480 gets the current date and time from the foo.bar.com NTP server for a location based on the Pacific Standard Time used in the United States.


Return to Commands Selection

Disclaimer: Amiga Auckland have prepared the above information for the use of its members based on our experiences and as such is subject to revision at any time. Amiga Auckland cannot guarantee any of the information and cannot be held accountable for any issues that may result from using it.

Copyright 2006 Amiga Auckland Inc. All rights reserved.
Revised: February 9, 2006.