Q(uick)BASIC Function: Now#
Quick View
Now#
A function that takes your computer's current system date and time and returns a serial number that represents this date and time
Worth knowing
Useful and cross-version information about the programming environments of QBasic and QuickBasic.
Syntax
- Now#
Description/Parameter(s)
Usage Notes
- For information on serial numbers, see ⮜ Serial Numbers ⮞.
Important
- To use Now# in the QBX environment, use the DTFMTER.QLB Quick library. To use Now# outside the QBX environment, link your program with the appropriate DTFMTxx.LIB file. Depending on the compiler options you chose when you installed BASIC, one or more of the following files will be available:
Filename | Compiler options |
DTFMTER.LIB | 80x87 or emulator math; DOS or OS/2 real mode |
DTFMTAR.LIB | Alternate math; DOS or OS/2 real mode |
DTFMTEP.LIB | 80x87 or emulator math, OS/2 protected mode |
DTFMTAP.LIB | Alternate math; OS/2 protected mode |
- The DATIM.BI header file contains the necessary function declarations for using Now#.
- For more information on using libraries, see "Creating and Using Quick Libraries" and "Using LINK and LIB" in the BASIC Programmer's Guide.
Example
This example uses the FormatD$ function to format date and time information. The current date and time are returned as a serial number by the Now# function.
Note: To run this example you must use a Quick library that includes the procedures contained in the date/time/format library files. The following include files must also be present.
'$INCLUDE: 'DATIM.BI'
'$INCLUDE: 'FORMAT.BI'
CLS
PRINT "Today's date is "; FormatD$(Now#, "dd-mmm-yy"); "."
PRINT "The correct time is "; FormatD$(Now#, "hh:mm:ss AM/PM"); "."
Sample Output:
Today's date is 02-May-1989. The correct time is 2:22:14 PM.