MDK下的gmtime函数怎么不能用啊?

[复制链接]
6201|9
 楼主| lg75 发表于 2012-11-17 15:35 | 显示全部楼层 |阅读模式
int main (void)
{
struct tm tmTimer,UTC;
time_t  ss;

tmTimer.tm_year = 2013 - 1900;
tmTimer.tm_mon = 2-1;
tmTimer.tm_mday = 28;
tmTimer.tm_hour = 0;
tmTimer.tm_min = 1;        
tmTimer.tm_sec = 2;

ss=mktime(&tmTimer);//转换成秒代表的年月日。经过对比测试,这个是OK的。
UTC=*gmtime(&ss);//转换成tm结构体。这个UTC再读出时就都是乱数据!
   return 0;
}


请高手指教,谢谢!
Ryanhsiung 发表于 2012-11-17 16:36 | 显示全部楼层
1、MDK编译条件下的库支持这个函数。
2、类型是否一致
3、是否声明此函数
wandersky 发表于 2012-11-19 09:59 | 显示全部楼层
tmTimer.tm_isdst=0;
加上这句试试
vgalcd 发表于 2012-11-20 10:33 | 显示全部楼层
2389676302 发表于 2012-11-20 16:40 | 显示全部楼层
这个看不懂
 楼主| lg75 发表于 2012-11-21 21:27 | 显示全部楼层
3# wandersky

加了也不行,奇怪。
 楼主| lg75 发表于 2012-11-21 21:28 | 显示全部楼层
2# Ryanhsiung

已经 #include "time.h"
编译没有错,但是运行结果就不对,奇怪。
Ryanhsiung 发表于 2012-11-22 13:01 | 显示全部楼层
莫非库有问题
weiyuliang 发表于 2013-8-14 16:25 | 显示全部楼层
好像存在这个问题ctime函数是可以正常运行的,
weiyuliang 发表于 2013-8-14 17:04 | 显示全部楼层
gmtime
语法:


  #include <time.h>
  struct tm *gmtime( const time_t *time );


功能:函数返回给定的统一世界时间(通常是格林威治时间),如果系统不支持统一世界时间系统返回NULL。 警告!
MDK不支持时区的 使用MDK不支持时区
localtime函数即可
localtime
语法:


  #include <time.h>
  struct tm *localtime( const time_t *time );


功能:函数返回本地日历时间。警告!

您需要登录后才可以回帖 登录 | 注册

本版积分规则

60

主题

205

帖子

2

粉丝
快速回复 在线客服 返回列表 返回顶部