TIME$ function

Purpose: TIME$ returns a character string containing the system time in 24 hr format.


 Syntax 1:

 RetStr$ = TIME$

 Parameters:

  • None.

 Return Value:

  • RetStr$, the return value, is a string containing the system time in 24 hour format.
 Syntax 2:

 RetStr$ = TIME$(Number%)

 Parameters:

  • Number% is an integer containing
    • 1 if the hour is to be returned
    • 2 if the minute is to be returned
    • 3 if the second is to be returned
    • 4 if the AM or PM is to be returned
    • 5 if the year is to be returned
    • 6 if the month is to be returned
    • 7 if the day is to be returned
    • 8 if the day name is to be returned
    • 9 if the week day is to be returned
    • 10 if the year day is to be returned
    • 11 if the week of year is to be returned

 Return Value:

  • RetStr$, the return value, is a string containing
    • hour if TIME$(1)
    • minute if TIME$(2)
    • second if TIME$(3)
    • AM or PM if TIME$(4)
    • year if TIME$(5)
    • month if TIME$(6)
    • day if TIME$(7)
    • day name if TIME$(8)
    • week day if TIME$(9)
    • day of year if TIME$(10)
    • week of year if TIME$(11)

Here is an example using macros.


 CONST TheHour$ = TIME$(1)
 CONST TheMINUTE$ = TIME$(2)
 CONST TheSECOND$ = TIME$(3)
 CONST TheAMPM$ = TIME$(4)
 CONST TheYEAR$ = TIME$(5)
 CONST TheMONTH$ = TIME$(6)
 CONST TheDAY$ = TIME$(7)
 CONST TheDAYNAME$ = TIME$(8)
 CONST TheWEEKDAY$ = TIME$(9)
 CONST TheYEARDAY$ = TIME$(10)
 CONST TheWEEK$ = TIME$(11)

 ? "Printing TIME$   "; TIME$
 ? "-----------------"
 ? "Printing HOUR    "; TheHour$
 ? "Printing MINUTE  "; TheMINUTE$
 ? "Printing SECOND  "; TheSECOND$
 ? "Printing AMPM    "; TheAMPM$
 ? "-----------------"
 ? "Printing YEAR    "; TheYEAR$
 ? "Printing MONTH   "; TheMONTH$
 ? "Printing DAY     "; TheDAY$
 ? "-----------------"
 ? "Printing DAYNAME "; TheDAYNAME$
 ? "Printing WEEKDAY "; TheWEEKDAY$
 ? "Printing YEARDAY "; TheYEARDAY$
 ? "Printing WEEK    "; TheWEEK$

BCX Console Sample Programs using TIME$ function.

S31.bas, S111.bas, S142.bas