time

来源:互联网 发布:香草天空知乎 编辑:程序博客网 时间:2024/06/06 00:46
#include<stdio.h>#include<time.h>#include<stdlib.h>int main(){        struct tm *tm_ptr;        time_t the_time;        int i;        the_time = time((time_t *)0);        printf("The time is %ld\n",the_time);        tm_ptr = gmtime(&the_time);        printf("%04d-%02d-%02d %02d:%02d:%02d\n",                1900+tm_ptr->tm_year, //从1900年开始                tm_ptr->tm_mon+1, //从0开始                tm_ptr->tm_mday,                tm_ptr->tm_hour,                tm_ptr->tm_min,                tm_ptr->tm_sec        );}

这里写图片描述
这里写图片描述

0 0
原创粉丝点击