非常实用的时间转化函数

上一篇 / 下一篇  2012-08-07 12:24:20 / 个人分类:C/C++

非常好用时间转换函数:
time();
localtime();
strftime();

具体使用参考:
struct tm *newtime;
char tmpbuf[128];   
time_t lt1;   
time(&lt1); //获取从1970年1月1日00:00:00(称为UNIX系统的Epoch时间)到当前时刻的秒数  
newtime=localtime(&lt1);  //把从1970-1-1零点零分到当前时间系统所偏移的秒数时间(即上述获取的lt1)转换为日历时间 
strftime( tmpbuf, 128, "Today is %A, day %d of %B in the year %Y.\n", newtime); //类似printf,按照一定的格式输出到tmpbuf


TAG:

 

评分:0

我来说两句

日历

« 2024-05-06  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 3521
  • 日志数: 13
  • 书签数: 3
  • 建立时间: 2012-08-01
  • 更新时间: 2012-12-30

RSS订阅

Open Toolbar