首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

C语言:获取当前时间,并转入字符串

2013-11-01 
C语言:获取当前时间,并转为字符串这个功能挺常用的,记录一下:#include time.h#include stdio.hint mai

C语言:获取当前时间,并转为字符串
这个功能挺常用的,记录一下:

#include <time.h>#include <stdio.h>int main(){time_t nowtime = time(NULL);tm *now = localtime(&nowtime);printf("now: %04d-%02d-%02d %02d:%02d:%02d\nunix time: %ld\n", now->tm_year+1900, now->tm_mon+1, now->tm_mday, now->tm_hour, now->tm_min, now->tm_sec, (long)nowtime);return 0;}

热点排行