datetime( ) 函数示例

第一个示例将新的年份存储在一个名为 tnewyear 的变量中,并且将当前的日期时间存储在名为 ttoday 的变量中。然后显示当前的日期时间与下一年此时之间的秒数。

第二个示例使用 datetime()函数创建与 2000 年兼容的日期时间值。

tnewyear = datetime(year(date( ) ) + 1, 1, 1)  && 下一个新年
ttoday = datetime( )
nsecondstonewyear = tnewyear - ttoday
clear
? "there are " + alltrim (str(nsecondstonewyear)) ;
   + " seconds to the next new year."
clear
set century on
set date to american
? datetime(1998, 02, 16, 12, 34, 56) && 显示 02/16/1998 12:34:56 pm