If we want to get just the date modified, for a file, in a format of our choosing. This can be done with a utility called stat.
The syntax is as follows:
-t " "
In this example, we are printing just the date created in the format YYYYMMDD_HHMMSS.
stat -f "%Sm" -t "%Y%m%d_%H%M%S" filename.txt
We are using the -f “%Sm flag to specify that we want to print out only the date modified. The -t “%Y%m%d_%H%M%S” sets the date format.
In my example, the output was:
This translates to November 30, 2012 at 18:02:21.