Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ms access VBA正在剪切返回不同时间的文件系统对象_Ms Access_Vba_Filesystemobject - Fatal编程技术网

Ms access VBA正在剪切返回不同时间的文件系统对象

Ms access VBA正在剪切返回不同时间的文件系统对象,ms-access,vba,filesystemobject,Ms Access,Vba,Filesystemobject,我遇到一个问题,返回文件的创建日期,如下所示: Set fsoFile = CreateObject("Scripting.FileSystemObject") Set File = fsoFile.GetFile([Path] & [Filename]) debug.print File.DateCreated 它返回的时间比windows资源管理器上显示的时间早一个小时 我不知道系统时间是否曾经改变过,或者是否有一段时间系统时间错误,但现在它肯定是正确的 有人知道这可能是什么/有类

我遇到一个问题,返回文件的创建日期,如下所示:

Set fsoFile = CreateObject("Scripting.FileSystemObject")
Set File = fsoFile.GetFile([Path] & [Filename])
debug.print File.DateCreated
它返回的时间比windows资源管理器上显示的时间早一个小时

我不知道系统时间是否曾经改变过,或者是否有一段时间系统时间错误,但现在它肯定是正确的

有人知道这可能是什么/有类似的问题吗


谢谢

您是在欧洲吗

官方文档指出,NTFS将文件日期存储为UTC时间,因此(目前)比您的本地时间少一小时

您可以通过以下方式找到当前UTC时间:

    Public Type SystemTime
        wYear                           As Integer
        wMonth                          As Integer
        wDayOfWeek                      As Integer
        wDay                            As Integer
        wHour                           As Integer
        wMinute                         As Integer
        wSecond                         As Integer
        wMilliseconds                   As Integer
    End Type

' Returns the current UTC time.
Private Declare PtrSafe Sub GetSystemTime Lib "kernel32" ( _
    ByRef lpSystemTime As SystemTime)

' Retrieves the current date and time from the local computer as UTC.
' By cutting off the milliseconds, the resolution is one second to mimic Now().
'
' 2016-06-09. Gustav Brock, Cactus Data ApS, CPH.
'
Public Function UtcNow() As Date

    Dim SysTime     As SystemTime
    Dim Datetime    As Date

    ' Retrieve current UTC date/time.
    GetSystemTime SysTime

    Datetime = _
        DateSerial(SysTime.wYear, SysTime.wMonth, SysTime.wDay) + _
        TimeSerial(SysTime.wHour, SysTime.wMinute, SysTime.wSecond)

    UtcNow = Datetime

End Function

然后使用DateDiff(“n”,UtcNow,Now)查找UTC时间和本地时间之间的差异,然后将其添加到检索到的文件时间中。

我在欧洲,这里面似乎有一些东西。所有我在时钟放回之前试过的文件,都是时差出来的。自从时钟放回后,我尝试过的所有文件都是正确的。DateDiff(“n”,UtcNow,Now)当前显示为0,因此将0添加到检索到的文件名中不会产生任何差异我猜这对于现在创建的文件名是正确的(如果本地时间和UTC时间之间没有差异,您就不想/不需要添加任何内容),但是如果你明白我的意思的话,加零并不能纠正时钟倒转之前创建的文件的时间。是的,我明白了。我在
UTC+01:00
。我对一些本地文件进行了测试,发现检索到的filedate是本地标准时间。这意味着,时间与DST外显示的时间相匹配,在DST内间隔一小时(我猜,此时无法在DST下进行测试)。另外,我发现
VBA.FileDateTime(filename)
返回
FSO.datelastmedited
值。例如,对于zip文件,
DateCreated
几乎总是与
DateLastModified
不同。是的,我试过DateLastModified,看看是否有什么不同。事实并非如此,相同的行为。此处提供更多信息:。