GMT时间字符串和time_t转换

Gosoft 2008-06-20 03:49:43
GMT时间字符串和time_t转换的问题,请问谁有源码码?能给我一份码?多谢!!
...全文
2272 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
长安宁 2008-06-28
  • 打赏
  • 举报
回复
能写一下,GMT时间字符串是个什么样子?
转换完成的GMT Unix时间戳是个什么样子吗?
Gosoft 2008-06-28
  • 打赏
  • 举报
回复
我需要的是 GMT时间字符串 转 GMT Unix时间戳的转换函数;可能是我一开始没有讲清楚。
Oversense 2008-06-21
  • 打赏
  • 举报
回复
GMT == 格林威治标准时间 == time_t

无需转
充电宝111 2008-06-20
  • 打赏
  • 举报
回复
GMT时间 = 普通时间(年月日时分秒) + 时区(一个整数)
K行天下 2008-06-20
  • 打赏
  • 举报
回复

struct timeval {
time_t tv_sec; /* seconds */
suseconds_t tv_usec; /* microseconds */
};

time_t time(time_t *); 获取当前时间为一个长整数
char * ctime(const time_t *);将时间结构time_t转换为字符串
char * asctime(const struct tm *);将tm结构转换为字符串
struct tm * gmtime(const time_t *);将时间结构转换为tm结构 GMT
struct tm * localtime(const time_t *);将时间结构转换为tm结构 LT
time_t mktime(struct tm *);将tm结构转换为time_t结构
double difftime(time_t, time_t);将前一个减去后一个的差额
clock_t clock(void);返回从“开启这个程序进程”到“程序中调用clock()函数”时之间的CPU时钟计时单元(clock tick)数

另外tm结构如下:
struct tm {
int tm_sec; /* seconds after the minute - [0,59] * /
int tm_min; /* minutes after the hour - [0,59] * /
int tm_hour; /* hours since midnight - [0,23] * /
int tm_mday; /* day of the month - [1,31] * /
int tm_mon; /* months since January - [0,11] * /
int tm_year; /* years since 1900 * /
int tm_wday; /* days since Sunday - [0,6] * /
int tm_yday; /* days since January 1 - [0,365] * /
int tm_isdst; /* daylight savings time flag * /
};



lala_benben 2008-06-20
  • 打赏
  • 举报
回复
time_t newtime;
time(&newtime);
strftime(szBuff, sizeof(szBuff),
"%Y/%m/%d %X %A", localtime(&newtime));

69,371

社区成员

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

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