VBScript Time 函数
定义和用法
Time 函数可返回当前的系统时间。
语法
Time
提示和注释
重要事项:
如果同时读取 Date、Time 以及 Now,那么 Now = Date + Time,但是实际上,我们不可能同时调用这三个函数,因为执行完一个函数之后,才能执行另一个函数,所以如果您在程序中必需同时取得当时的日期和时间,必需调用 Now,再利用 DateVale 及 TimeValue 分别取出日期和时间。Example: Obtain the date and time of a specific time point:
N = Now 'this time point's date and time D = Datevalue(N) 'same time point's date part T = TimeValue(N) 'same time point's time part D2 = Date 'time point 1's date T2 = Time 'time point 2's time
Problem Thinking
What is the maximum possible error value when executing Response.write Now and Response.Write Date + Time continuously? Assumption:
The Now obtained from time point 1 = #7/1/95 23:59:59# The Date obtained from time point 2 = #7/1/95#
And if the 'time point 3' just crosses a day, so Time = #0:00:00, then the difference between Now and Date+Time becomes 23:59:59.
Instance
Example 1
document.write(Time)
Output:
14:34:38
Note:The output results may vary slightly due to different computer settings.