-2

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?

  • 2
    Is the manual that hard?: http://www.qbasic.net/en/reference/qb11/Function/TIME_.htm, http://www.qbasic.net/en/reference/qb11/Function/DATE_.htm – Clifford Feb 17 '18 at 09:24

3 Answers3

1

You can use DATE$ and TIME$

These can also set the date and time as well.

Bryant1003
  • 316
  • 2
  • 11
1

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...

0

The QB date/time functions are:

DATE$ returns the date in a string in the form MM-DD-YYYY

TIME$ returns the time in a string in the form HH:MM:SS

When used as a command the date$ and time$ can be assigned to set the system date and time, for example DATE$ = "12-10-1990" or TIME$ = "12:10:10"

If the year is a leap year then the 29th day of February could be set. Otherwise if it is not a leap year then a syntax error will occur trying to set the date in February to the 29th.

eoredson
  • 1,167
  • 2
  • 14
  • 29
  • A leap year is any year evenly divisible by 4. If the year is evenly divisible by 100 then it is not. If the year is evenly divisible by 400 then it is. – eoredson Feb 18 '18 at 00:37