#include <time.h>
struct tm *localtime(const time_t *timep);
struct tm {
int tm_sec; /* seconds */
int tm_min; /* minutes */
int tm_hour; /* hours */
int tm_mday; /* day of the month */
int tm_mon; /* month */
int tm_year; /* year */
int tm_wday; /* day of the week */
int tm_yday; /* day in the year */
int tm_isdst; /* daylight saving time */
};
/ELAMPLE
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
#include <unistd.h>
int main(void)
{
struct stat sta;
struct tm* time;
int fid;
if((fid=open("log",O_RDONLY | O_CREAT, 0664))==-1)
perror("open");
else
printf("成功%d\n",fid);
if(lstat("log",&sta)==-1)
{
perror("lstat");
return -1;
}
printf("%d\n",(int)sta.st_dev);
printf("%d\n",(int)sta.st_uid);
printf("%d\n",(int)sta.st_dev);
printf("%d\n",(int)sta.st_atime);
time=localtime(&sta.st_atime);
printf("%d:%d:%d\n",time->tm_year+1900,time->tm_mon+1,time->tm_sec);
close(fid);
}