C C++ 获取当前系统时间到字符串

来源:互联网 发布:网络配音cv大神 编辑:程序博客网 时间:2024/05/17 18:14

头文件

#include <time.h>
#include <stdlib.h>

char *pszCurrTime = (char*)malloc(sizeof(char)*20);
memset(pszCurrTime, 0, sizeof(char)*20);

time_t now;
 time(&now);
 strftime(pszCurrTime, 20 , "%Y/%m/%d %H:%M:%S", localtime(&now));

时间格式即为 2011/07/08 11:13:44

原创粉丝点击