Liberty BASIC Help Online |
Date and Time Functions
Liberty BASIC provides several ways to retrieve date and time information. Date$() and Time$() are functions that return values that can be used in mathematical operations. See also Date$ and Time$
Date$()
'This form of date$() produces this format
print date$() ' Nov 30, 1999 |
print date$("mm/dd/yyyy") ' 11/30/1999
print date$("mm/dd/yy") ' 11/30/99
print date$("yyyy/mm/dd") ' 1999/11/30 for sorting
print date$("days") ' 36127 days since Jan 1, 1901
print date$("4/1/2002") ' 36980 days since Jan 1, 1901 for given date
print date$(36980) ' 04/01/2002 mm/dd/yyyy string returned
' when given days since Jan 1, 1901
Date$() Math
Here is a small program that demonstrates one way that Date$() can be used with math operators.
today = date$("days")
target = date$("1/1/2004") 'subsititute value for next year
print "Days until the new year: ";
print target - today
Time$()
'this form of time$() produces this format
print time$() 'time now as string "16:21:44" |
print time$("seconds") 'seconds since midnight as number 32314
print time$("milliseconds") 'milliseconds since midnight as number 33221342
print time$("ms") 'milliseconds since midnight as number 33221342
Time$() Math
Here is a small program that demonstrates one way that Time$() can be used with math operators.
'get start time
startTime = time$("ms")
'do some computations
for i = 1 to 40000
x = x + i
next
'get end time
endTime=time$("ms")
print "Computations took ";
print endTime-startTime; " milliseconds"
end
Copyright (C) 2003 Shoptalk Systems
Liberty BASIC - http://www.libertybasic.com/