Chapter
10
I
BASIC Keywords
TIME$
Function
TIME$[
=
string]
Sets
or
retrieves the current time.
String
is a literal, enclosed in quotation marks, that sets the
time by assigning its value
to
TIME$. If you omit
string,
BASIC
retrieves the current time.
BASIC uses
a
24-hour clock. For example, it sets 8:15 P.M. as
20:15:00.
Setting the Time
You set the time in the following format:
hh:mm:ss
The hours
(hh)
may be any number 0-23.
The minutes
(mm)
and the seconds
(ss)
may be any number
0 through 59.
If you omit the minutes, minutes
and
seconds default
to
zero. If you omit the seconds, seconds default
to
zero.
Although you may omit leading zeros in each
of
the values, you
must include
at
least
1
digit of the preceding value.
For
example,
you may type 1:5 to set the the time to 1:05 A.M. However,
:5
is
invalid.
Retrieving the Time
BASIC always returns the time in the 8-character (hh:mm:ss)
format, with leading zeros. You may set the time before you enter
BASIC. If you do not set the time
at
the MS-DOS time prompt
or
with the TIME$ statement, BASIC returns the length
of
the
time that has elapsed since you turned on the computer.
328