VBScript中的Now()精度 [英] Now() Accuracy in VBScript

查看:77
本文介绍了VBScript中的Now()精度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Now()似乎以秒精度返回10,000,000的时间.在尝试使用此方法编写now的更准确实现时,返回

Now() in VBScript appears to return time in 10,000,000th of a second precision when called as CDbl(Now()). In attempting to use this to write a more accurate implementation of now which returns CIM_DATETIME format I found that in VBScript, despite being particularly precise, is not very accurate with the time only updating once per second. This can be demonstrated by watching the output from what follows:

i = 0
While i < 50
    gnow = Cdbl(now) 
    result = (gnow - Int(gnow))
    WScript.Echo CDate(gnow)
    WScript.Echo "Iteration " & i & ": " & result
    WScript.Sleep(100)
    i = i + 1
Wend

我现在要回答的问题是,给定一个运行不到一秒钟的VBScript调用Now(),Now()将返回什么时间?是脚本解释器启动的时间,调用Now()的时间还是其他时间?

The question I'm now trying to answer is, given a VBScript that runs for less than a second which calls Now(), what time will be returned by Now()? Is it the time that the script interpreter started, the time when Now() was called, or something else?

推荐答案

似乎是时候将"Now()"方法精确到秒了.仍然是正常的方法调用.

It looks like it will be the time the "Now()" method was called accurate to the second. It's still a normal method invocation.

这篇关于VBScript中的Now()精度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆