IBM Support

How can I get the modified date of an IFS file.

Question & Answer


Question

How can I get the modified date of an IFS file?

Answer

There are a couple of ways to see the modified date of an IFS file. Using WRKLNK option 8 can be used to display the attributes. A programming solution can use the STAT API, or using the PASE/QSHELL support.



The Qshell or PASE method would use attr - Get or set attributes for files
The attribute operand MODIFY_TIME returns the date and time the object was created.
In this example the directory /home/bimbra will get searched for the pattern *.txt, and print the item(s) that match, and for each item found, execute the attr utility to print the file creation date.
find /home/bimbra -name '*.txt' -print -exec attr {} MODIFY_TIME \;
Sample output returned:-
/home/bimbra/function.txt
Sun Jun 29 13:28:04 2014
/home/bimbra/sftp1.txt
Mon Feb 8 13:42:29 2016
/home/bimbra/properties/xajava.properties.txt
Wed Aug 27 12:18:58 2014

The RPG programming sample solution presented in this DCF is using api STAT api.
This credit for this sample goes to Scott Klement http://archive.midrange.com/rpg400-l/200105/msg00320.html

STAT api returns the time as epoch time.
This RPG Free sample also shows how to convert epoch time into human readable time!
This sample retrieves Last Access, Last Modified and Status Changed time.

Note: If you need to get IFS file creation date then Qp0lGetAttr() API will need to be used.

UID

nas8N1021185