VBS实现将当前时间转换成UTC时间
例如下面的代码在当前时间返回:1368299689
OptionExplicit
DimdtmDate
IfWScript.Arguments.Named.Count>0ThenSyntax
WithWScript.Arguments.Unnamed
'Checkcommandlinearguments
If.Count=0ThendtmDate=Now
If.Count>0ThendtmDate=.Item(0)
If.Count>1ThendtmDate=dtmDate&""&.Item(1)
If.Count>2ThendtmDate=dtmDate&""&.Item(2)
If.Count>3ThenSyntax
OnErrorResumeNext
dtmDate=CDate(dtmDate)
IfErrThen
OnErrorGoto0
Syntax
EndIf
OnErrorGoto0
IfNotIsDate(dtmDate)ThenSyntax
EndWith
'Calculateanddisplaytheresult
WScript.EchoDateDiff("s","1970-01-0100:00:00",dtmDate)
SubSyntax
WScript.Echovbcrlf_
&"Date2UTC.vbs,Version1.00"_
&vbCrLf_
&"Convertanydate/timetoUnixtime(UTC)"_
&vbCrLf&vbCrLf_
&"Usage:CSCRIPT.EXE//NoLogoDate2UTC.vbsdate[time]"_
&vbCrLf&vbCrLf_
&"Where:""date""isthedatetoconvert(default:currentdate/time)"_
&vbCrLf_
&"""time""istheoptionaltimetoconvert"_
&vbCrLf&vbCrLf_
&"Notes:ThoughoftencalledUTC,Unixtimedoesnottakeintoaccountleap"_
&vbCrLf_
&"seconds,while""official""UTCdoes."_
&vbCrLf_
&"Ifthespecifieddateisambiguous,thecurrentuser'sdate"_
&vbCrLf_
&"andtimeformatisassumed."_
&vbCrLf&vbCrLf_
&"WrittenbyRobvanderWoude"_
&vbCrLf_
&"http://www.robvanderwoude.com"
WScript.Quit1
EndSub
以上所述就是本文的全部内容了,希望大家能够喜欢。