关于时间函数,该如何处理

关于时间函数
time_t createTime = mailInfo->getCreateTime()/1000;
tm* t = localtime(&createTime);
int hour_createTime = t->tm_hour;
int minute_createTime = t->tm_min;

不知道这段代码有什么问题,经常会使程序崩溃,这时
t 和createTime 显示的值 一个是全部都是1,另一个是第一个是1后跟着的都是0

求大侠帮助,万分感谢!!!
------解决方案--------------------
估计是 time_t createTime = mailInfo->getCreateTime()/1000; 赋值溢出
------解决方案--------------------
求大侠帮助,万分感谢!!! 

楼主要 万分感谢么?
关于时间函数,该如何处理

没什么大问题,先确定能不能正确获取秒数的问题!
------解决方案--------------------
引用:
Quote: 引用:

估计是 time_t createTime = mailInfo->getCreateTime()/1000; 赋值溢出


溢出的话如何处理好点啊?

溢出时用最大值覆盖?
time_t createTime = (mailInfo->getCreateTime()/1000 > ((time_t)1<<(sizeof(time_t)-1)))?((time_t)1)<<(sizeof(time_t)-1):mailInfo->getCreateTime()/1000;

------解决方案--------------------
溢出了就判断localtime的返回值是不是NULL就可以了
Return a pointer to the structure result, or NULL if the date passed to the function is:

Before midnight, January 1, 1970.

After 03:14:07, January 19, 2038, UTC (using _time32 and time32_t).

After 23:59:59, December 31, 3000, UTC (using _time64 and __time64_t).