VBS显示当前标准时间(vb显示当前时间的代码是什么)越早知道越好

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


Option Explicit

Dim blnDate, blnTime
Dim dtmDate
Dim intDay, intFormat, intHour, intMin, intMonth, intSec, intUTC, intValid, intYear
Dim strISO

With WScript.Arguments
‘ Check command line arguments
If .Unnamed.Count=0 Then dtmDate=Now
If .Unnamed.Count > 0 Then dtmDate=.Unnamed(0)
If .Unnamed.Count > 1 Then dtmDate=dtmDate & ” ” & .Unnamed(1)
If .Unnamed.Count > 2 Then dtmDate=dtmDate & ” ” & .Unnamed(2)
If .Unnamed.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
intValid=0
blnDate=True
blnTime=True
If .Named.Exists( “D” ) Then
blnDate=True
blnTime=False
intValid=intValid + 1
End If
If .Named.Exists( “T” ) Then
blnDate=False
blnTime=True
intValid=intValid + 1
End If
If intValid <> .Named.Count Then Syntax
If intValid > 1 Then Syntax
End With

‘ Format the output string
intYear=DatePartLZ( “yyyy”, dtmDate )
intMonth=DatePartLZ( “m”, dtmDate )
intDay=DatePartLZ( “d”, dtmDate )
intHour=DatePartLZ( “h”, dtmDate )
intMin=DatePartLZ( “n”, dtmDate )
intSec=DatePartLZ( “s”, dtmDate )
If blnDate Then strISO=intYear & “-” & intMonth & “-” & intDay
If blnTime Then strISO=strISO & ” ” & intHour & “:” & intMin & “:” & intSec
‘ Display the result
WScript.Echo Trim( strISO )

Function DatePartLZ( myInterval, myDate )
‘ Add a leading zero to the DatePart() if necessary
Dim strDatePart
strDatePart=DatePart( myInterval, myDate )
If Len( strDatePart ) < 2 Then strDatePart=”0″ & strDatePart
DatePartLZ=strDatePart
End Function

Sub Syntax
WScript.Echo vbcrlf _
& “Date2ISO.vbs, Version 1.02” _
& vbCrLf _
& “Convert any date/time to ISO date/time” _
& vbCrLf & vbCrLf _
& “Usage: CSCRIPT.EXE //NoLogo Date2ISO.vbs date [ time ] [ /D | /T ]” _
& vbCrLf & vbCrLf _
& “Where: “”date”” is the date to convert (default: current date/time)” _
& vbCrLf _
& ” “”time”” is the optional time to convert” _
& vbCrLf _
& ” /D return date only (default: both date and time)” _
& vbCrLf _
& ” /T return time only (/D and /T are mutually exclusive)” _
& vbCrLf & vbCrLf _
& “Note: 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

© 版权声明

相关文章