VBScript中的UTC时间分配 [英] UTC Time Assignment in VBScript

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

问题描述

有人在VBScript中有一种简单的方法来获取UTC的当前时间吗?

Does anyone have a simple means in VBScript to get the current time in UTC?

感谢,克里斯(

Thanx, Chris

推荐答案

我使用一种简单的技术

Set dateTime = CreateObject("WbemScripting.SWbemDateTime")    
dateTime.SetVarDate (now())
wscript.echo  "Local Time:  " & dateTime
wscript.echo  "UTC Time: " & dateTime.GetVarDate (false)

有关SWbemDateTime的更多信息

如果您想将UTC转换回本地时间执行此操作:

If you wanted to convert UTC back to local time do this:

Set dateTime = CreateObject("WbemScripting.SWbemDateTime")
        dateTime.SetVarDate now(),false  REM Where now is the UTC date
        wscript.echo cdate(dateTime.GetVarDate (true))

这篇关于VBScript中的UTC时间分配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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