|List of all BASIC keywords|
Type: System variable as string General Programming-Syntax: TIME$ or TI$
A system variable of the C64 is TIME$ (short: TI$). TIME$ contains the actually time of the C64 as string with a length of 6 chars in the hours, minutes and seconds (format: HHMMSS) since the last reseting.
Note that TIME$ follows just the expanded variable name scheme and therefore any character suitable as variable name (letter, digit) after TI is silently ignored, for example TICKAMASALA$ will still refer to TI$. The common usage how it can be found in program listing is the short variant TI$.
The time of the C64 is started by power-on, after a reset or after setting with
TI$="000000" in programs. The updating of the time take the internal hardware-interval-timer of the Commodore 64, which is setting in the system variable TIME (short: TI). Also TI will be affected by setting of TIME$.
Logical values of TIME$ are strings corresponding to the HH:MM:SS time notification with values ranging from "000000" to "235959". If TI$ exceeds the value "235959" the timer value wraps around to 0 for TI and "000000" for TIME$. Any activity which prevents the IRQ interrupt processing may lead to inaccuracy by some extent, so the TI$ can never be considered as a real-time clock. Especially by using the datasette the clock will be stopped while loading, saving or verifying.
If TIME$ is not assigned with a string, the BASIC error ?TYPE MISMATCH ERROR appears. Setting TIME$ with with strings which does not consist of exactly 6 decimal digits causes the BASIC error ?ILLEGAL QUANTITY ERROR.
Even though "235959" is the largest logical value one may read from TIME$, "774020" is the largest value that TIME$ can be set to. If TIME$ is set to a string between "774021" and "999999" then the resulting TIME$ value will be entered value minus 774021. For example, if you type
TI$="888888":?TI$, the output will be "114907" and 888888-774021=114867, and since 67 seconds = 1 minute 07 seconds, then the resulting time is 114907.
10 REM Clock simulation, cancel with RUN/STOP 20 TIME$="235800" : REM Setting a new time for overflow! 30 T$=TIME$ : REM Save the time to avoid a overflow! 40 PRINT CHR$(147); 50 PRINT LEFT$(T$,2);":"; 60 PRINT MID$(T$,3,2);":"; 70 PRINT RIGHT$(T$,2) 80 GOTO 30
The updated time is shown at the upper, left corner on the screen.
100 TI$="000000" 110 WAIT 162,64
This program waits approx. 1 second by means using a trick with the WAIT command: it is awaiting a change of the low byte timer value at bit 6 from 0 to 1. After the low byte is set to 0 and the timer counts to 64, which takes 64 jiffies (64/60 sec.). This code won't break by pushing , just with + combination!