婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > VBS顯示當前標準時間

VBS顯示當前標準時間

熱門標簽:哪里有便宜的地圖標注公司 除了地圖標注還有這種生意嗎 如何用機器人進行電銷 地圖標注政府哪個部門管 百度地圖標注點距離代碼 佛山真人電銷機器人廠家 東營快遞外呼系統 齊齊哈爾高德地圖標注店 神行者美術館地圖標注

VBS顯示當前標準時間,例如:執行下面的代碼則顯示:2013-05-11 19:10:11

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

附上一段VBS校對系統時間的代碼給大家參考下

'VBS校準系統時間 BY BatMan 
Dim objXML, Url, Message 
Message = "恭喜你,本機時間非常準確無需校對!" 
Set objXML = CreateObject("MSXML2.XmlHttp") 
Url = "http://open.baidu.com/special/time/" 
objXML.open "GET", Url, False 
objXML.send() 
Do Until objXML.readyState = 4 : WScript.Sleep 200 : Loop 
Dim objStr, LocalDate 
objStr = objXML.responseText 
LocalDate = Now() 
Set objXML = Nothing 
Dim objREG, regNum 
Set objREG = New RegExp 
objREG.Global = True 
objREG.IgnoreCase = True 
objREG.Pattern = "window.baidu_time\((\d{13,})\)" 
regNum = Int(objREG.Execute(objStr)(0).Submatches(0)) /1000 
Dim OldDate, BJDate, Num, Num1 
OldDate = "1970-01-01 08:00:00" 
BJDate = DateAdd("s", regNum, OldDate) 
Num = DateDiff("s", LocalDate, BJDate) 
If Abs(Num) >=1 Then 
Dim DM, DT, TM, objSHELL 
DM = DateAdd("S", Num, Now()) 
DT = DateValue(DM) 
TM = TimeValue(DM) 
If InStr(Now, "午") Then 
Dim Arr, Arr1, h24 
Arr = Split(TM, " ") 
Arr1 = Split(Arr(1), ":") 
h24 = Arr1(0) 
If Arr(0) = "下午" Then 
h24 = h24 + 12 
Else 
If h24 = 12 Then h24 = 0 
End If 
TM = h24  ":"  Arr1(1)  ":"  Arr1(2) 
End If 
Set objSHELL = CreateObject("Wscript.Shell") 
objSHELL.Run "cmd /cdate "  DT, False, True 
objSHELL.Run "cmd /ctime "  TM, False, True 
Num1 = Abs(DateDiff("s", Now(), BJDate)) 
Message = "【校準前】"  vbCrLf _ 
 "標準北京時間為:"  vbTab  BJDate  vbCrLf _ 
 "本機系統時間為:"  vbTab  LocalDate  vbCrLf _ 
 "與標準時間相差:"  vbTab  Abs(Num)  "秒"  vbCrLf  vbCrLf _ 
 "【校準后】"  vbCrLf _ 
 "本機系統時間為:"  vbTab  Now()  vbCrLf _ 
 "與標準時間相差:"  vbTab  Num1  "秒" 
Set objSHELL = Nothing 
End If 
WScript.Echo Message 

以上所述就是本文的全部內容了,希望對大家學習VBS能夠有所幫助。

您可能感興趣的文章:
  • 用vbscript實現修改屏幕保護的等待時間長度
  • 將WMI中的DateTime類型轉換成VBS時間的函數代碼
  • 用VBS修改(設置)系統時間和日期的代碼
  • 校準系統時間的VBS代碼
  • VBS中獲取系統本次及上次開關機時間的代碼(WinXP/win2003/Win7兼容版)
  • vbscript實現的根據不同時間段顯示不同的歡迎語
  • vbs獲取當前時間日期的代碼
  • vbscript獲取文件的創建時間、最后修改時間和最后訪問時間的方法
  • VBS實現將當前時間轉換成UTC時間

標簽:四平 鶴壁 湖州 文山 西安 海口 銅川 邢臺

巨人網絡通訊聲明:本文標題《VBS顯示當前標準時間》,本文關鍵詞  VBS,顯示,當前,標準時間,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《VBS顯示當前標準時間》相關的同類信息!
  • 本頁收集關于VBS顯示當前標準時間的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 湖南省| 灯塔市| 高唐县| 乌兰浩特市| 卫辉市| 灌云县| 铁力市| 阳谷县| 保山市| 武胜县| 双江| 延长县| 集安市| 东明县| 甘肃省| 仙居县| 东方市| 北宁市| 彩票| 图们市| 祁东县| 济宁市| 奈曼旗| 桂东县| 札达县| 广宗县| 新邵县| 大兴区| 灌南县| 亳州市| 南充市| 斗六市| 甘谷县| 肇州县| 西青区| 香格里拉县| 岐山县| 罗田县| 隆回县| 崇礼县| 班戈县|