VBS实现将当前时间转换成UTC时间(vb实时输出数据)真没想到

随心笔谈2年前发布 编辑
166 0
🌐 经济型:买域名、轻量云服务器、用途:游戏 网站等 《腾讯云》特点:特价机便宜 适合初学者用 点我优惠购买
🚀 拓展型:买域名、轻量云服务器、用途:游戏 网站等 《阿里云》特点:中档服务器便宜 域名备案事多 点我优惠购买
🛡️ 稳定型:买域名、轻量云服务器、用途:游戏 网站等 《西部数码》 特点:比上两家略贵但是稳定性超好事也少 点我优惠购买


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

© 版权声明

相关文章