Sqlite3 时间格式定制 毫秒数 两位小数

    #include 
    #include 


     struct timeval tv;
     char buf2[64];

     gettimeofday(&tv, NULL);
     char buf[128] = {0};
     strftime(buf2, sizeof(buf)-1, "%Y%m%d%H%M%S", localtime(&tv.tv_sec));
     sprintf(buf, "%s.%02d", buf2, (int)(tv.tv_usec / 1000/10));
     string Time(buf);
    char msdate[10];
    char msh[3];
    char msm[3];
    char mss[3];
    char msms[3];

    string DateTime;
    sprintf(msdate,"%02d",Date);
    DateTime.append(msdate);
    sprintf(msh,"%02d",Hour);
    DateTime.append(msh);
    sprintf(msm,"%02d",Minute);
    DateTime.append(msm);
    sprintf(mss,"%02d",.Second);
    DateTime.append(mss);

YYYYMMDDTHHMMSSSS

http://blog.sina.com.cn/s/blog_648d306d0102wpcq.html

你可能感兴趣的:(C++,C)