VBScript Now function
Definition and usage
The Now function of VBScript can return the current date and time based on the date and time settings of the computer system.
Syntax
Now
Tips and comments
Important matters:
If Date, Time, and Now are read simultaneously, then Now = Date + Time; however, it is impossible to call all three functions at the same time, as one function must be executed before another. Therefore, if you need to obtain the current date and time simultaneously in your program, you must call Now first and then use DateValue and TimeValue to extract the date and time.Example: Obtain the date and time of a specific time point:
N = Now 'the date and time of this time point D = Datevalue(N) 'the date part of the same time point T = TimeValue(N) 'the time part of the same time point D2 = Date 'time point 1's date T2 = Time 'time point 2's time
Problem Thinking
What is the maximum possible error when executing Response.write Now and Response.Write Date + Time continuously? Assumptions:
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, then Time = #0:00:00, so the difference between Now and Date+Time becomes 23:59:59.
Instance
Example 1
document.write(Now)
Output:
2007-10-1 14:10:06
Note:The output may vary slightly due to different computer settings.