VBS到格式日期日期:星期二,2022年11月18日15:57:11+ 0000

发布于 2025-02-07 02:51:07 字数 749 浏览 1 评论 0原文

因此,我试图以可读格式正确格式化日期。

这是我的代码。

WScript.Echo(DateDiff("s", "01/01/1970 00:00:00", Now()))

Function sprintf(sFmt, aData)
   With CreateObject("System.Text.StringBuilder")
      .AppendFormat_4 sFmt, (aData)
      sprintf = .ToString()
      .Length = 0
   End With
End Function

Dim CurrTime  : CurrTime = Now()
Dim Elapsed   : Elapsed = Timer()
Dim MilliSecs : MilliSecs = Right("000" & Int((Elapsed - Int(Elapsed)) * 1000), 3)

'echo "Date: " . date("D, d M Y H:i:s O");
'Date: Tue, 18 Nov 2014 15:57:11 +0000

WScript.Echo "Date: ", sprintf( "{0:yyyy/MM/dd HH:mm:ss}", Array(CurrTime)) & "." & MilliSecs

我想实现的输出是这个

Date: Tue, 18 Nov 2022 15:57:11 +0000

,但我缺少分配

So I am trying to format my date properly in a readable format.

Here is my code.

WScript.Echo(DateDiff("s", "01/01/1970 00:00:00", Now()))

Function sprintf(sFmt, aData)
   With CreateObject("System.Text.StringBuilder")
      .AppendFormat_4 sFmt, (aData)
      sprintf = .ToString()
      .Length = 0
   End With
End Function

Dim CurrTime  : CurrTime = Now()
Dim Elapsed   : Elapsed = Timer()
Dim MilliSecs : MilliSecs = Right("000" & Int((Elapsed - Int(Elapsed)) * 1000), 3)

'echo "Date: " . date("D, d M Y H:i:s O");
'Date: Tue, 18 Nov 2014 15:57:11 +0000

WScript.Echo "Date: ", sprintf( "{0:yyyy/MM/dd HH:mm:ss}", Array(CurrTime)) & "." & MilliSecs

The output i am trying to achieve is this

Date: Tue, 18 Nov 2022 15:57:11 +0000

But i am missing allot

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

对你的占有欲 2025-02-14 02:51:07
Function sprintf(sFmt, aData)
   With CreateObject("System.Text.StringBuilder")
      .AppendFormat_4 sFmt, (aData)
      sprintf = .ToString()
      .Length = 0
   End With
End Function
Dim CurrTime  : CurrTime = Now()
WScript.Echo WeekdayName(Weekday(Now()),True) & ", " & Day(Now()) & " " & MonthName(Month(Now()),True) & " " & sprintf( "{0:yyyy HH:mm:ss}", Array(CurrTime)) & " +0000"

想出了一种方法来获取我想要的输出。

Function sprintf(sFmt, aData)
   With CreateObject("System.Text.StringBuilder")
      .AppendFormat_4 sFmt, (aData)
      sprintf = .ToString()
      .Length = 0
   End With
End Function
Dim CurrTime  : CurrTime = Now()
WScript.Echo WeekdayName(Weekday(Now()),True) & ", " & Day(Now()) & " " & MonthName(Month(Now()),True) & " " & sprintf( "{0:yyyy HH:mm:ss}", Array(CurrTime)) & " +0000"

Figured out a way to get the output i wanted.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文