函数原型:
复制代码 代码如下:
size_t strftime (char* ptr, size_t maxsize, const char* format,const struct tm* timeptr );
代码示例:
复制代码 代码如下:
#include <stdio.h>
#include <time.h>
int main ()
{
time_t rawtime;
struct tm * timeinfo;
char buffer [128];
time (&rawtime);
timeinfo = localtime (&rawtime);
strftime (buffer,sizeof(buffer),"Now is %Y/%m/%d %H:%M:%S",timeinfo);
puts (buffer);
return 0;
}
时间: 2024-11-13 07:34:45