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

时间:2012-02-14 13:43:43

标签: vbscript timezone wmi jscript

我有一个在PST机器上创建/修改的文件。但是当我从印度标准时间访问此文件时,将根据当前系统时区返回修改日期。 (正如所解释的那样here)我是否可以根据提供的时区获得此日期

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

1 个答案:

答案 0 :(得分:0)

是的,您可以使用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中你可以这样做:

How to calculate date difference in javascript