怎么将这个值转换成标准的时间格式呢

怎么将这个值转换成标准的时间格式呢

如何将这个值转换成标准的时间格式呢?
从系统文件中读到一个数值
btime   769041601                
系统文件是这样说明的:boot   time,   in   seconds   since   the   epoch   (January   1,   1970).
我的问题是如何将这个数值转换成通常的标准时间格式,如同struct   tm结构一样可操作呢?


time_t cur;
struct tm *loca;
cur=769041601;
loca=locatime(&cur);
printf( "%4d-%2d-%2dn ",tm-> tdate-> tm_year,tdate-> tm_mon,tdate-> tm_mday);

#include <time.h>
int main()
{
time_t cur;
struct tm *loca;
cur = 769041601;
loca = localtime(&cur);
printf( "%4d-%2d-%2dn ",loca-> tm_year,loca-> tm_mon,loca-> tm_mday);
}
编译运行得到的结果为:
94- 4-16

关于time_t类型,可参考文章“C/C++中的日期和时间, time_t与struct tm转换”,地址如下
http://hi.baidu.com/ggplyx/blog/item/46ec7ed0965e048ea1ec9c4e.html
文章中解释了time_t其实就是一长整型的秒数。

怎么将这个值转换成标准的时间格式呢

相关文章:

你感兴趣的文章:

标签云: