1. 转化从1970年来的秒数到年月日时分秒格式
#include <time.h>
{
struct tm *local;
local=localtime(&time);
strftime(buf,30,"%Y-%m-%d %H:%M:%S",local);
}
char buf[30];
seconds2ymdhms(buf, FileInfo.time_write);
2. 转化年月日时分秒格式到从1970年来的秒数
#include <time.h>
struct tm time;
time_t t;
time.tm_year=nyear-1900;
time.tm_mon=nmonth - 1;
time.tm_mday=nday;
time.tm_hour=nhour;
time.tm_min=nminute;
time.tm_sec=nsecond;
time.tm_isdst=0;
t=mktime(&time);
本文介绍了两种时间格式之间的转换方法:一种是从1970年以来的秒数转换为年月日时分秒格式;另一种是从年月日时分秒格式转换为自1970年以来的秒数。通过使用C语言中的标准库函数实现。

2151

被折叠的 条评论
为什么被折叠?



