本篇内容介绍了“VBS怎么实现将当前时间转换成UTC时间”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
例如下面的代码在当前时间返回:1368299689
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
“VBS怎么实现将当前时间转换成UTC时间”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。
原文链接:https://www.jb51.net/article/66263.htm