-
VBS实现将当前时间转换成UTC时间
这篇文章主要介绍了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
复制
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
以上所述就是本文的全部内容了,希望大家能够喜欢。
来源:https://www.jb51.net/article/66263.htm
最新更新
VBS显示当前标准时间
VBS实现将当前时间转换成UTC时间
VBS脚本写的Windows硬件检测工具分享
vb下的恶搞关机程序
vbs脚本实现修改DNS和清空IE临时文件功能
使用Java实现KMZ和KML数据的直接解析
Spring Boot最经典的20道面试题你都会了吗
Java中Instant的使用及转换
Spring中ClassPath指的是哪些地方
在SpringBoot项目中使用JetCache缓存的详细教
SQL SERVER中递归
2个场景实例讲解GaussDB(DWS)基表统计信息估
常用的 SQL Server 关键字及其含义
动手分析SQL Server中的事务中使用的锁
openGauss内核分析:SQL by pass & 经典执行
一招教你如何高效批量导入与更新数据
天天写SQL,这些神奇的特性你知道吗?
openGauss内核分析:执行计划生成
[IM002]Navicat ODBC驱动器管理器 未发现数据
初入Sql Server 之 存储过程的简单使用
uniapp/H5 获取手机桌面壁纸 (静态壁纸)
[前端] DNS解析与优化
为什么在js中需要添加addEventListener()?
JS模块化系统
js通过Object.defineProperty() 定义和控制对象
这是目前我见过最好的跨域解决方案!
减少回流与重绘
减少回流与重绘
如何使用KrpanoToolJS在浏览器切图
performance.now() 与 Date.now() 对比