用c++获取系统的时间后,发现时间的格式是int型,并且我们需要的格式是类似2015-07-24 15:55:03这种类型的格式,为此将这些int型的年月日时分秒转换为string,而MySQL中datetime型的格式为'2015-07-24 15:55:03',那么问题来了:怎么将"2015-07-24 15:55:03"转换成'2015-07-24 15:55:03',从而sql语句能够插入当前时间。
相关代码如下:
int转string:
用c++获取系统的时间后,发现时间的格式是int型,并且我们需要的格式是类似2015-07-24 15:55:03这种类型的格式,为此将这些int型的年月日时分秒转换为string,而MySQL中datetime型的格式为'2015-07-24 15:55:03',那么问题来了:怎么将"2015-07-24 15:55:03"转换成'2015-07-24 15:55:03',从而sql语句能够插入当前时间。
相关代码如下:
int转string: