utc时间算法

chengchaog 2009-04-02 05:00:23
utc时间起点是1970-1-1 00:00:00
以秒为单位
比如传过来的秒是:1238654434

我怎么算出来时间出来,

帮忙写下详细的算法
...全文
1856 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
liliangbao 2009-04-03
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 HelloDan 的回复:]
C/C++ code
#include<stdio.h>
#include<time.h>
int main()
{
//struct tm *ptr;
time_t lt;
lt =1238654434;
printf("The Calendar Time now is %d\n",lt);
printf(ctime(<));

return 0;
}
[/Quote]
正解!
tanlee007 2009-04-02
  • 打赏
  • 举报
回复
引用9楼的东东:
C/C++ code
#include<stdio.h>
#include<time.h>
int main()
{
//struct tm *ptr;
time_t lt;
lt =1238654434;
printf("The Calendar Time now is %d\n",lt);
printf(ctime(<));

return 0;
}
HelloDan 2009-04-02
  • 打赏
  • 举报
回复
http://sysuor.blog.163.com/blog/static/8620131200610501218985/
HelloDan 2009-04-02
  • 打赏
  • 举报
回复

#include<stdio.h>
#include<time.h>
int main()
{
//struct tm *ptr;
time_t lt;
lt =1238654434;
printf("The Calendar Time now is %d\n",lt);
printf(ctime(<));

return 0;
}


chengchaog 2009-04-02
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 HelloDan 的回复:]
C/C++ code
#include<stdio.h>
#include<time.h>
int main()
{
//struct tm *ptr;
time_t lt;
lt =time(NULL);
printf("The Calendar Time now is %d\n",lt);
printf(ctime(<));

return 0;
}
[/Quote]

老大你这个是系统时间
我要的是1238654434秒的时间
chengchaog 2009-04-02
  • 打赏
  • 举报
回复
找不到
caixin99 2009-04-02
  • 打赏
  • 举报
回复
查一下msdn,有例子。
chengchaog 2009-04-02
  • 打赏
  • 举报
回复
还有转换成标准的时间2009-01-01 01:01:01
  • 打赏
  • 举报
回复
如果是linux下直接有指令可以实现

--把秒数转换成标准时间格式(方法1)
$ date -d '1970-1-1 0:0:0 GMT + 1233631748 seconds'
Tue Feb 3 11:29:08 CST 2009

--把秒数转换成标准时间格式(方法2)
$ date -d @1233631748
Tue Feb 3 11:29:08 CST 2009
mengde007 2009-04-02
  • 打赏
  • 举报
回复
http://msdn.microsoft.com/zh-cn/library/bb546098.aspx
  • 打赏
  • 举报
回复
http://download.csdn.net/source/1168366
UTC2Time utc秒数时间与日期时间转换工具
HelloDan 2009-04-02
  • 打赏
  • 举报
回复

#include<stdio.h>
#include<time.h>
int main()
{
//struct tm *ptr;
time_t lt;
lt =time(NULL);
printf("The Calendar Time now is %d\n",lt);
printf(ctime(<));

return 0;
}


69,382

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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