Chinaunix首页 | 论坛 | 博客
  • 博客访问: 45931
  • 博文数量: 9
  • 博客积分: 1410
  • 博客等级: 上尉
  • 技术积分: 165
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-21 11:40
文章分类
文章存档

2008年(9)

我的朋友
最近访客

分类: C/C++

2008-05-30 17:12:27

#include
#include
using namespace std;
 
int main(int argc,char *argv[])
{
        char now[64];
        time_t tt;
        struct tm *ttime;
        tt = atol(argv[1]);
        //tt = 1212132599;
        //time(&tt);
        ttime = localtime(&tt);
        strftime(now,64,"%Y-%m-%d %H:%M:%S",ttime);
        cout << "the time is " << now << endl;
}
 
 
编译后执行:
./strtotime 1212132599
 
输出为:
the time is 2008-05-30 15:29:59
 
阅读(4712) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~