DT.GetCurrent

Previous  Next

 

str = DT.GetCurrent( format-str AS STRING = "%c" ) AS STRING

 


 

Get the current date and/or time as a string formatted according to the format specified.  See DT.Format for more information about the format specified.

 

Example:

 

$LIBRARY "MyBASIC2_ExtLib"

$INCLUDE "MyBASIC2_ExtLib"

 

CLS

 

DIM strDate AS STRING

DIM strTime AS STRING

DIM strDT AS STRING

DIM iCmp AS INTEGER

 

strDT = DT.Format( "%c", 2020, 3, 3, 23, 59, 59 )

 

PRINT "Old Date: ";strDT,

PRINT "New Date: ";DT.GetCurrent(),

 

' Use Random Number Generator to test a comparison

SELECT CASE ROUND( RND * 2 )

  CASE 0:

     iCmp = DT.Compare( DT.GetCurrent(), strDT )

  CASE 1:

     iCmp = DT.Compare( strDT, DT.GetCurrent() )

  CASE 2:

     iCmp = DT.Compare( strDT, strDT )

ENDSELECT

 

SELECT CASE iCmp

  CASE -1:

     PRINT DT.GetCurrent();" is before ";strDT,

  CASE 0:

     PRINT strDT;" is the same time as ";DT.GetCurrent(),

  CASE 1:

     PRINT strDT;" is later than ";DT.GetCurrent(),

  CASE ELSE

     PRINT "System is either drunk or messed up !",

ENDSELECT

 

PRINT "[End]",

 

END