Search code examples
datetimeqbasic

How to print current Time and Date in Q Basic?


What is the command for displaying the time and date in qbasic? Could the syntax for the commands be given as well? And an explanation if possible?


Solution

  • The command for printing the time(current system time) is time$ The time$ is actually a function, in this case, no parameter is needed.

    And the code is...

     PRINT TIME$
    

    The time is printed in hh: mm: ss format(hour: minutes: seconds).

    And therefore the output would be something like this:

    14:55:28
    

    For printing the current system date, we use date$ function which is also a string function

    The code is:

    PRINT DATE$
    

    The date is printed in mm-dd-yyyy format or month-day-year(American date format).

    Hence the output will be:

    02-17-2018
    

    Hope it helps...