将格林威治时间转换为字符串

来源:互联网 发布:蓝博清单计价软件 编辑:程序博客网 时间:2024/04/30 08:50
将格林威治时间转换为字符串
头文件 : #include<time.h>
函数原型:char *asctime(const struct tm *tm)
函数功能:将格林威治时间转换为字符串
参 数:指向 struct tm 结构体指针
返 回 值 :字符串指针
范 例:
#include<stdio.h>
#include<time.h>
int main()
{
time_t t;
char *time_str;
struct tm *gmt;
t=time(NULL);
gmt = gmtime(&t); //将日历时间转换为格林威治标准时间:
time_str = asctime(gmt); //将格林威治时间转换为字符串
printf("time_str = %s \n",time_str);
}
运行结果:
time_str =Thu Feb 9 08:34:43 2017
原创粉丝点击