Function 5700h Get File Date and Time

mov bx, Handle ;handle of file

mov ax, 5700h ;Get Date and Time

int 21h

jc error_handler ;carry set means error

mov FileTime, cx ;time file was last modified

mov FileDate, dx ;date file was last modified

Get File Date and Time (Function 5700h) retrieves the time and date a file was last modified (the last time its directory entry was updated).

Parameter

Handle

Identifies the file to retrieve the date and time for.

Return Value

If the function is successful, the carry flag is clear, the CX register contains the time the file was last modified, and the DX register contains the date the file was last modified. Otherwise, the carry flag is set and the AX register contains an error value, which may be 0006h (ERROR_INVALID_HANDLE).

Comments

The file time returned in CX is a 16-bit value with the following format:

Bits Contents

0–4 Second divided by 2
5–10 Minute (0–59)
11–15 Hour (0–23 on a 24-hour clock)

The file date returned in DX is a 16-bit value with the following format:

Bits Contents

0–4 Day of the month (1–31)
5–8 Month (1 = January, 2 = February, etc.)
9–15 Year offset from 1980 (add 1980 to get actual year)

See Also

Function 5701h Set File Date and Time