标准CC++获取当前时间(毫秒级)

来源:互联网 发布:个人简介网站html源码 编辑:程序博客网 时间:2024/05/16 12:20

直接上代码了

#include<sys/timeb.h>void getSystemTime(string& stime){timeb t;        ftime(&t);char tmp[16];strftime(tmp,sizeof(tmp),"%Y%m%d%H%M%S",localtime(&t.time));//Year Month Day Hour Minute Secondchar tm[20];sprintf(tm, "%s%d",tmp,t.millitm);stime=tm;}void main(){           string nowtime;//存储获取的系统的时间       getSystemTime(nowtime);}



0 0
原创粉丝点击