现在的位置: 首页 > 综合 > 正文

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

2013年09月15日 ⁄ 综合 ⁄ 共 228字 ⁄ 字号 评论关闭

#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

抱歉!评论已关闭.