mov bx, Handle ;handle of file
mov cx, FileTime ;new file time
mov dx, FileDate ;new file date
mov ax, 5701h ;Set Date and Time
int 21h
jc error_handler ;carry set means error
Set File Date and Time (Function 5701h) sets the time and date for a file, replacing the time and date set for the file when it was last modified.
Handle
Identifies the file to set the date and time for.
FileTime
Specifies the new time for the file. The file time 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) |
FileDate
Specifies the new date for the file. The file date 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) |
If the function is successful, the carry flag is clear. Otherwise, the carry flag is set and the AX register contains an error value, which may be 0006h (ERROR_INVALID_HANDLE).
Function 5700h Get File Date and Time