Tools: MPW
Advanced Search
Apple Developer Connection
Member Login Log In | Not a Member? Support

MPW Command Reference


Date

Built-in

SYNTAX

Date [[-a | -s | -s4 | -u] [-c num | -utc] [-d | -t] [-st]] |
[[-n] | [-utc]] | [-x date]

DESCRIPTION

The Date command writes the current date and time to standard output. The command supports date arithmetic that works with the number of seconds since midnight, January 1, 1904 (-n and -c).

INPUT

None

OUTPUT

Standard output. Without any options the Date output has the following form:

Thursday, April 18, 1996 2:40:51 P.M.

STATUS

Date can return the following status codes:

0

no errors

1

syntax error

PARAMETERS

None

OPTIONS

-a

Generates an abbreviated date with three-character abbreviations for the month and day of the week. For example,

Thu, Apr 11, 1991

-c num

Writes the date corresponding to num, which is interpreted as the number of seconds since midnight, January 1, 1904. You can use the other output format options with -c to specify the output format.

-d

Writes the date only.

-n

Returns a numeric value for the current date and time in terms of the number of seconds since midnight, January 1, 1904. This option is useful for date and time arithmetic.

-s

Generates a shortened date and time with numeric values for the date. The day of the week is not given. For example,

8/30/99 10:45:51

-s4

The same as -s except 4 digits are used for the year. For example,

8/30/1999 10:45:51

-st

Omits seconds when displaying the time.

-t

Writes the time only.

-u

Displays the date in MPW uniform format as shown below

yyyymmdd hh:mm:ss  (Note: ◊ is Option-Shift-v.)

where yyyy, mm, and dd represent the year, month, and day; and hh, mm, and ss represent the hour, minute, and second. Note that when specifying the hour, the values 0 thru 11 indicate A.M. time while the values 12 thru 23 indicate P.M. time.

-utc

Adjusts the output to Universal Time Coordinates.

-x date

Writes the seconds corresponding to date. This is the inverse of the -c option.

EXAMPLES

Using both -s and -d causes Date to exclude the time and return just the date in a shortened form. For instance,

Date -s -d

returns

4/11/91

This example demonstrates how date arithmetic can be used to show how long a tool or script takes to execute.

Set starttime `Date -n`
BuildMyProgram
Set endTime `Date -n`
Echo Total time for BuildMyProgram ∂
`Evaluate {endTime} - {startTime}`

 
 


Last Updated July 2000