VBS converts the current time to UTC time

Source: Internet
Author: User

VBS converts the current time to UTC time

This article mainly introduces how to convert the current time to UTC time by using VBS. It is very simple and practical. For more information, see

For example, the following code returns at the current time: 1368299689

?

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

43

44

45

46

47

48

49

50

51

52

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

 

'Calculate and display the result

WScript. Echo DateDiff ("s", "00:00:00", dtmDate)

 

 

Sub Syntax

WScript. Echo vbcrlf _

& "Date2UTC. vbs, Version 1.00 "_

& VbCrLf _

& "Convert any date/time to Unix time (UTC )"_

& VbCrLf _

& "Usage: CSCRIPT. EXE // NoLogo Date2UTC. vbs date [time]" _

& VbCrLf _

& "Where:" "date" "is the date to convert (default: current date/time )"_

& VbCrLf _

& "Time" "is the optional time to convert "_

& 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 _

& "Written by Rob van der Woude "_

& VbCrLf _

& "Http://www.robvanderwoude.com"

WScript. Quit 1

End Sub

The above is all the content of this article. I hope you will like it.

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.