当前位置: 代码网 > it编程>前端脚本>其它脚本 > VBS实现将当前时间转换成UTC时间

VBS实现将当前时间转换成UTC时间

2024年05月19日 其它脚本 我要评论
例如下面的代码在当前时间返回:1368299689option explicit dim dtmdate if wscript.arguments.named.count > 0 then sy

例如下面的代码在当前时间返回:1368299689

option explicit
 
dim dtmdate
 
if wscript.arguments.named.count > 0 then syntax
 
with wscript.arguments.unnamed
  ' check command line arguments
  if .count = 0 then dtmdate = now
  if .count > 0 then dtmdate = .item(0)
  if .count > 1 then dtmdate = dtmdate & " " & .item(1)
  if .count > 2 then dtmdate = dtmdate & " " & .item(2)
  if .count > 3 then syntax
  on error resume next
  dtmdate = cdate( dtmdate )
  if err then
    on error goto 0
    syntax
  end if
  on error goto 0
  if not isdate( dtmdate ) then syntax
end with
 
' calculate and display the result
wscript.echo datediff( "s", "1970-01-01 00:00:00", dtmdate )
 
 
sub syntax
  wscript.echo vbcrlf _
        & "date2utc.vbs, version 1.00" _
        & vbcrlf _
        & "convert any date/time to unix time (utc)" _
        & vbcrlf & vbcrlf _
        & "usage: cscript.exe //nologo date2utc.vbs date [ time ]" _
        & vbcrlf & vbcrlf _
        & "where: ""date""  is the date to convert (default: current date/time)" _
        & vbcrlf _
        & "    ""time""  is the optional time to convert" _
        & vbcrlf & vbcrlf _
        & "notes: though often called utc, unix time does not take into account leap" _
        & vbcrlf _
        & "    seconds, while ""official"" utc does." _
        & vbcrlf _
        & "    if the specified date is ambiguous, the current user's date" _
        & vbcrlf _
        & "    and time format is assumed." _
        & vbcrlf & vbcrlf _
        & "written by rob van der woude" _
        & vbcrlf _
        & "http://www.robvanderwoude.com"
  wscript.quit 1
end sub

以上所述就是本文的全部内容了,希望大家能够喜欢。

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com