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
以上所述就是本文的全部内容了,希望大家能够喜欢。
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短