VBS实现将当前时间转换成UTC时间
程序员文章站
2022-03-21 16:30:42
例如下面的代码在当前时间返回:1368299689
option explicit
dim dtmdate
if wscript.argument...
例如下面的代码在当前时间返回: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
以上所述就是本文的全部内容了,希望大家能够喜欢。
上一篇: java程序设计原则知多少
下一篇: 关于java数组与字符串相互转换的问题