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 送芒果的祝福语简短
18 送给学长毕业祝福语简短