您的位置:首页 > 编程语言 > C语言/C++

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

2013-10-13 11:56 288 查看
头文件

#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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: