TIME$ function

Purpose:

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

Syntax 1:

RetStr = TIME$

Return Value:

  • Data type: STRING
    RetStr The system time in 24 hour format.

Parameters:

  • None.

Syntax 2:

RetStr = TIME$(0, NonZero AS INTEGER)

Return Value:

  • Data type: STRING
    RetStr The system time expressed as Coordinated Universal Time in 24 hour format.

Parameters:

  • Data type: INTEGER
    0 A zero flag specifying that the return should be the system time in 24 hour format.
  • Data type: INTEGER
    NonZero [OPTIONAL] A non-zero integer specifying that the return should be Coordinated Universal Time.

Syntax 3:

RetStr = TIME$(Number AS INTEGER)

Return Value:

Parameters:

  • Data type: INTEGER
    Number A non-zero 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
    • 12 if 12 hour A.M./P.M. format is to be returned

Syntax 4:

RetStr = TIME$(Number AS INTEGER, NonZero AS INTEGER)

Return Value:

  • Data type: STRING
    RetStr Contains the Coordinated Universal Time

Parameters:

  • Data type: INTEGER
    Number Contains
    • 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
    • 12 if 12 hour A.M./P.M. format is to be returned
  • Data type: INTEGER
    NonZero [OPTIONAL] A non-zero integer specifying that the return should be Coordinated Universal Time.

Here is an example using macros.

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

? "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$
? "Printing AMPM12  "; TheAMPM12$

Result:

Printing TIME$   17:51:36
-----------------
Printing HOUR    17
Printing MINUTE  51
Printing SECOND  36
Printing AMPM    PM
-----------------
Printing YEAR    1908
Printing MONTH   06
Printing DAY     28
-----------------
Printing DAYNAME Sunday
Printing WEEKDAY 0
Printing YEARDAY 180
Printing WEEK    26
Printing AMPM12  05:51:36 PM

Here is an example using macros and the UTC optional parameter.

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

? "Printing UTC TIME$   "; TIME$(0, 1)
? "-----------------"
? "Printing UTC HOUR    "; TheHour$
? "Printing UTC MINUTE  "; TheMINUTE$
? "Printing UTC SECOND  "; TheSECOND$
? "Printing UTC AMPM    "; TheAMPM$
? "-----------------"
? "Printing UTC YEAR    "; TheYEAR$
? "Printing UTC MONTH   "; TheMONTH$
? "Printing UTC DAY     "; TheDAY$
? "-----------------"
? "Printing UTC DAYNAME "; TheDAYNAME$
? "Printing UTC WEEKDAY "; TheWEEKDAY$
? "Printing UTC YEARDAY "; TheYEARDAY$
? "Printing UTC WEEK    "; TheWEEK$
? "Printing UTC AMPM12  "; TheAMPM12$

Result:

Printing UTC TIME$   00:54:46
-----------------
Printing UTC HOUR    00
Printing UTC MINUTE  54
Printing UTC SECOND  46
Printing UTC AMPM    AM
-----------------
Printing UTC YEAR    1908
Printing UTC MONTH   06
Printing UTC DAY     29
-----------------
Printing UTC DAYNAME Monday
Printing UTC WEEKDAY 1
Printing UTC YEARDAY 181
Printing UTC WEEK    26
Printing UTC AMPM12  12:54:46 AM

BCX Console Sample Programs using the TIME$ function.