Q(uick)BASIC Statement: TIME$
Quick View
TIME$
A statement that uses DOS to set the current time
Worth knowing
Useful and cross-version information about the programming environments of QBasic and QuickBasic.
Syntax
- TIME$
- TIME$ = stringexpression$
Description/Parameter(s)
- The TIME$ function returns the computer's current system time.
- The TIME$ statement sets the current system time on your computer.
stringexpression$ | The time in one of the following forms: | |||||
|
||||||
The TIME$ function returns a string in the form hh:mm:ss. |
Example
PRINT TIME$
TIME$ = "08:00:58" 'Note: The new system time remains in effect until
' you change it again.
PRINT "Time set to "; TIME$
See also:
Syntax
- TIME$=stringexpression
Description/Parameter(s)
The stringexpression must be in one of the following forms:
Form | Description |
hh | Sets the hour; minutes and seconds default to 00 |
hh:mm | Sets the hour and minutes; seconds default to 00 |
hh:mm:ss | Sets the hour, minutes, and seconds |
A 24-hour clock is used - so, 8:00 PM would be entered as 20:00:00.
This statement complements the TIME$ function, which returns the current time.
Example
The following example sets the current time to 8:00 AM:
'*** TIME$ statement programming example ***
' Do not run this program unless you want to set
' your system clock to 8 a.m.
'
TIME$="08:00:00"
See also:
Syntax
- TIME$ = stringexpression$
Description/Parameter(s)
stringexpression$ | The time in one of the following forms:
|
The TIME$ statement changes the system time, which stays changed until you change it again or reboot your computer.
Usage Notes
- A 24-hour clock is used, so 8:00 P.M. would be entered as 20:00:00.
- This statement complements the TIME$ function, which returns the current time.
Example
This example sets the current time to 8:00 AM using the TIME$ statement.
'Do not run this program unless you want to reset your system clock.
TIME$ = "08:00:00"
See also: