如何获取到文件的创建时间,修改时间等参数

来源:互联网 发布:python csv文件 求和 编辑:程序博客网 时间:2024/06/06 02:29
        百度一下,发现有
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
 
void main( void )
{
    struct stat buf;
    int result;
 
    //获得文件状态信息
 
    result =stat( "/home/WCDJ/linux", &buf );
 
    //显示文件状态信息
 
   if( result != 0 )
       perror"显示文件状态信息出错" );//
 
    else
    {
 
        printf("文件大小: %d", buf.st_size);
        printf("文件创建时间: %s"ctime(&buf.st_ctime));
        printf("访问日期: %s"ctime(&buf.st_atime));
        printf("最后修改日期: %s"ctime(&buf.st_mtime));
     
    }
 
}
但是获取到的时间格式是这样的 Jan  1 08:00 
实际上我要的时间格式是 2014/05/16 12:05:38 :不需要英文字符,就要阿拉伯,还要详细到年月日。
只能
再尝试别的办法了。
0 0
原创粉丝点击