I am working on a C program where I need to get the last modified time of the file. What the program does is a function loops through each file within a directory and when a
This is one of those cases where timezones matter. You're getting gmtime of the st_mtime. You should instead be using localtime viz.
strftime(date, 20, "%d-%m-%y", localtime(&(attrib.st_ctime)));
this is because ls uses your timezone information, and when you used gmtime as part of the display, it deliberately omitted any timezone information.