如何在 Jscript 中获取文件相对于特定时区的文件修改日期?

发布于 2025-01-05 08:58:42 字数 418 浏览 1 评论 0原文

我有一个在 PST 机器上创建/修改的文件。但是当我从印度标准时间访问此文件时,将根据当前系统时区返回修改日期。 (正如此处所解释的)有什么方法可以让我尊重这个日期到提供的时区

var WshShell = Sys.OleObject("WScript.Shell");
var fso = new ActiveXObject("Scripting.FileSystemObject");           
var objFile = fso.GetFile("c:\\abc.txt");
var date = objFile.DateLastModified + "";

I have a file which gets created/modified on a PST machine. But when I am accessing this file from an Indian standard time, the Modified date will be returned according to the current system time zone. (As explained here) Is there any way I can get this date with respect to the time zone provided

var WshShell = Sys.OleObject("WScript.Shell");
var fso = new ActiveXObject("Scripting.FileSystemObject");           
var objFile = fso.GetFile("c:\\abc.txt");
var date = objFile.DateLastModified + "";

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

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

发布评论

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

评论(1

漆黑的白昼 2025-01-12 08:58:42

是的,您可以使用 VBS 中的 DateDiff 函数来执行此操作:

http://www. devguru.com/technologies/vbscript/quickref/datediff.html

DevGuru 信息

DateDiff(Interval, Date1, Date2, FirstDayofWeek, FirstWeekofYear)

The DateDiff function calculates the amount of time between two different dates.
There are three mandatory arguments.

Interval

The Interval argument defines the the type of time interval you wish to use to
calculate the time difference.

Only the following settings can be used. You must place the setting inside a
pair of double quotes.   

| SETTING | DESCRIPTION  |
|:--------|:-------------|
| YYYY    | Year         |
| Q       | Quarter      |
| M       | Month        |
| Y       | Day Of Year  |
| D       | Day          |
| W       | WeekDay      |
| WW      | Week Of Year |
| H       | Hour         |
| N       | Minute       |
| S       | Second       |

在 javascript 中,您可以这样做:

如何计算javascript中的日期差异

Yes, you do this with the DateDiff function in VBS:

http://www.devguru.com/technologies/vbscript/quickref/datediff.html

DevGuru Info

DateDiff(Interval, Date1, Date2, FirstDayofWeek, FirstWeekofYear)

The DateDiff function calculates the amount of time between two different dates.
There are three mandatory arguments.

Interval

The Interval argument defines the the type of time interval you wish to use to
calculate the time difference.

Only the following settings can be used. You must place the setting inside a
pair of double quotes.   

| SETTING | DESCRIPTION  |
|:--------|:-------------|
| YYYY    | Year         |
| Q       | Quarter      |
| M       | Month        |
| Y       | Day Of Year  |
| D       | Day          |
| W       | WeekDay      |
| WW      | Week Of Year |
| H       | Hour         |
| N       | Minute       |
| S       | Second       |

In javascript you can do it like this:

How to calculate date difference in javascript

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