VBS displays current standard Time

Source: Internet
Author: User
Tags abs command line current time echo message goto

This article to share is the use of VBS to display the current time 2 instances, very simple and practical, the need for small partners can refer to.

VBS displays the current standard time, for example: The following code is displayed: 2013-05-11 19:10:11

?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26-27--28 29---30 31--32 33 34 35 36 37 38-39 40 41 42 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 5 86 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, MyD ATE) ' 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 _ &" "", "" is the optional Ti Me to convert "_ & VbCrLf _ &"/D return date only (Default:both date and Time) "_ & VbCrLf _ &"/T RET Urn time only (/d and/t are mutually exclusive) "_ & VbCrLf & VbCrLf _ &" Note:if The specified date is Ambi Guous, 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

Attach a section of the VBS proofing system time code for you to refer to the following

?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 The ' VBS CALIBRATION system time by BatMan Dim Objxml, URL, message message = "Congratulations, this machine time is very accurate without proofreading!" "Set Objxml = CreateObject (" msxml2.xmlhttp ") url =" http://open.baidu.com/special/time/"Objxml.open" get ", url, False ob Jxml.send () do Until objxml.readystate = 4:wscript.sleep 200:loop Dim objstr, localdate objstr = Objxml.responsetext L Ocaldate = Now () Set objxml = Nothing Dim objreg, regnum Set objreg = New RegExp = True Objreg.global = 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, "midday") Then Dim Arr, Arr1, h24 Arr = SPL It (TM, "") Arr1 = Split (ARR (1), ":") H24 = Arr1 (0) If Arr (0) = "PM" Then h24 = h24 + Else If h24 = 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 (), B JDate)) message = "" Pre-Calibration "" & VbCrLf _ & "Standard Beijing time is:" & VbTab & Bjdate & VbCrLf _ & "The Local System time is:" & V Btab & Localdate & VbCrLf _ & "with Standard Time difference:" & VbTab & Abs (Num) & "SEC" & VbCrLf & VbCrLf _ ; "" After Calibration "" & VbCrLf _ & "The Local System time is:" & VbTab & Now () & VbCrLf _ & "and the Standard Time difference:" & VbTab & Num1 &am P "Seconds" Set Objshell = Nothing end If wscript.echo message

The above is the full content of this article, I hope to learn from the VBS can help.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.