Function Reference


FileGetTime

Returns the time and date information for a file.

FileGetTime ( "filename" [, option = 0 [, format = 0]] )

Parameters

filename The path to the file or directory to check.
option [optional] Flag to indicate which timestamp
$FT_MODIFIED (0) = Last modified (default)
$FT_CREATED (1) = Created
$FT_ACCESSED (2) = Last accessed

Constants are defined in FileConstants.au3
format [optional] to specify type of return
$FT_ARRAY (0) = return an array (default)
$FT_STRING (1) = return a string YYYYMMDDHHMMSS
$FT_MSEC (2) = return Milliseconds
$FT_UTC (4) = return UTC time instead of Local time

Constants are defined in FileConstants.au3

Return Value

Success: an array or string that contains the file time information. See Remarks.
Failure: sets the @error flag to non-zero.

Remarks

The array is a single dimension array containing six or seven elements:
$aArray[0] = year (four digits)
$aArray[1] = month (range 01 - 12)
$aArray[2] = day (range 01 - 31)
$aArray[3] = hour (range 00 - 23)
$aArray[4] = min (range 00 - 59)
$aArray[5] = sec (range 00 - 59)
If "format" includes $FT_MSEC and $FT_ARRAY you get
$aArray[6] = msec (range 00 - 999)

If "format" includes $FT_MSEC and $FT_STRING FileGetTime returns a string YYYYMMDDHHMMSSnnn

Notice that return values are zero-padded.

Related

FileGetAttrib, FileGetSize, FileGetVersion, FileSetAttrib, FileSetTime

Example

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
Example()
Func  Example()
; Create a constant variable in Local scope of the filepath that will be read/written to.
Local Const $sFilePath= _WinAPI_GetTempFileName (@TempDir )
; Set the modified timestamp of the file to 1st Nov 2003 and use the current time.
Local $iFileSetTime= FileSetTime ($sFilePath,"20031101",$FT_MODIFIED)
; Display the modified timestamp of the file and return as a string in the format YYYYMMDDHHMMSS.
If $iFileSetTimeThen
MsgBox ($MB_SYSTEMMODAL,"","Timestamp:"&@CRLF &FileGetTime ($sFilePath,$FT_MODIFIED,$FT_STRING))
Else
MsgBox ($MB_SYSTEMMODAL,"","An error occurred whilst setting the timestamp of the file.")
EndIf
; Delete the temporary file.
FileDelete ($sFilePath)
EndFunc ;==>Example

AltStyle によって変換されたページ (->オリジナル) /