VBS:返回格式化日期 [英] VBS: Return formatted date
本文介绍了VBS:返回格式化日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在执行一个返回另一个文件的修改日期的 VBS 文件:
I am executing a VBS file that returns the modified date of another file:
Set objFS=CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
strFile= objArgs(0)
WScript.Echo objFS.GetFile(strFile).DateLastModified
但是我希望在返回之前将日期格式化为 dd/MM/yyyy.
However I want the date to be formatted to dd/MM/yyyy before it is returned.
推荐答案
你可以把文件的修改日期拿出来稍微拆开一下..
You could just take the date modified of the file and pick it apart a bit..
因此,如果上次修改日期是 2014 年 11 月 30 日,则无论区域 PC 设置如何(FormatDateTime() 忽略),都将返回 30/11/2014
So if the last modified date was 11/30/2014, this would return 30/11/2014 regardless of regional PC settings (which FormatDateTime() ignores)
WScript.Echo convertDate(objFS.GetFile(strFile).DateLastModified)
Function convertDate(strDate)
convertDate = DatePart("d", strDate) & "/" & DatePart("m", strDate) & "/" & DatePart("yyyy", strDate)
End Function
这篇关于VBS:返回格式化日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文