请问:MySql中取出的日期字段的值,如何变成c语言中的time_t 或则 struct tm??

gordenfl 2004-08-08 03:12:56
如题,谢谢!!!!!!!!!
...全文
301 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
peter9606 2004-08-11
  • 打赏
  • 举报
回复
Row[i] 是什么类型的?
搂主最好说详细点
gordenfl 2004-08-11
  • 打赏
  • 举报
回复
我的意思是从Mysql中取出来的Row[i]这么一个东西,怎么转化成char * 的东西!
peter9606 2004-08-09
  • 打赏
  • 举报
回复
你的意思是mysql中的都是字符串么?

可以采用变通的办法呀
因为struct tm中的各个成员都是基本类型的



Data Fields
int tm_sec
int tm_min
int tm_hour
int tm_mday
int tm_mon
int tm_year
int tm_wday
int tm_yday
int tm_isdst

你一个一个的转换然后结构体就出来啦~
gordenfl 2004-08-09
  • 打赏
  • 举报
回复
我的意思是如何把字符串变成日期类型
peter9606 2004-08-08
  • 打赏
  • 举报
回复
搂主从mysql中得到的时间是什么形式的?
如果是time_t类型的就可以用下面的函数

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



The function localtime() converts calendar time time into local time.





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



The gmtime() function returns the given time in Coordinated Universal Time (usually Greenwich mean time), unless it's not supported by the system, in which case NULL is returned.
peter9606 2004-08-08
  • 打赏
  • 举报
回复
mysql中的时间信息你都取得了 然后附值给struct tm不就可以了?
gordenfl 2004-08-08
  • 打赏
  • 举报
回复
就是不会写该怎么写?
peter9606 2004-08-08
  • 打赏
  • 举报
回复
自己写一个转换函数不就可以了?

69,381

社区成员

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

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