code:
/*
mysql的日期是datetime型,c++中插入的时候可以用满足datetime格式的字符串(年-月-日 时:分:秒),
CTime获取系统时间,但是获取的是每个位置(年,月,日...)的数字,
可以配合CString的Format方法使用,这样就能用CString存datetime了.
*/
#include <atltime.h>
CTime t = CTime::GetCurrentTime();
CString time;
time.Format("%d-%02d-%02d %02d:%02d:%02d",
t.GetYear(),t.GetMonth(),t.GetDay(),t.GetHour(),t.GetMinute(),t.GetSecond());
//time里面存的就是datetime了