怎么取出文件的最后修改日期和时间??

qdh2002 2002-12-15 09:30:21
用stat函数取出一个stat结构,但里面的时间全是以1970年开始的秒值,有没有办法将其转成日期和时间??我觉得这个转换太复杂了。谢谢。
...全文
89 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
mazurka 2002-12-17
  • 打赏
  • 举报
回复
秒->时间用localtime
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 */
};
mazurka 2002-12-16
  • 打赏
  • 举报
回复
stat(filename,&st);

st.st_ctime 时间(秒)
st.st_ctime_usec 微秒
ari 2002-12-16
  • 打赏
  • 举报
回复
1.stat
2.cftime
chen9771 2002-12-16
  • 打赏
  • 举报
回复
up

23,120

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧