What does the value returned by st_mtime in the stat structure mean?

What does the value returned by st_mtime in the stat structure mean?

Post by vacati » Sat, 22 Dec 1990 13:16:34



I am writing a UNIX system program to retrieve file information
using the stat system call.

In my code I have the following lines:

     struct stat statbuf;

     stat (filename,&statbuf);

     printf ("%ld",statbuf.st_mtime);

This prints out a number like 661742557 for the time the contents
of the file were last modified.
What does this number mean and how would I convert to more
intelligible format (such as day/month/year hour:minute) if
possible ?

Any comments would be much appreciated.
Ralph Blake   Melbourne, Australia

 
 
 

What does the value returned by st_mtime in the stat structure mean?

Post by Dave Jen » Sat, 22 Dec 1990 14:28:47



Quote:

>In my code I have the following lines:

>     stat (filename,&statbuf);

>     printf ("%ld",statbuf.st_mtime);

>This prints out a number like 661742557 for the time the contents
>of the file were last modified.
>What does this number mean and how would I convert to more
>intelligible format (such as day/month/year hour:minute) if
>possible ?

This is the number of seconds since 00:00:00 GMT  Jan  1 1970.
To convert it to something `meaningful', such as the ASCII string
in my previous sentence, use ctime(3).
--
=======================================================================
            "Pro is to con, as progress is to Congress..."
=======================================================================