Use stat to get the last modified time (mtime) of a file. Read the man page (using man 2 stat) to learn how to call stat. The field of the stat struct that you want is called st_mtim on Linux. 

The struct timespec st_mtim; has two fields, one for seconds (tv_sec) and one for nanoseconds (tv_nsec). You will need both of these values to find out which time is more recent.