1.輸出unix時間戳,和本地時間
#include<time.h> #include<stdio.h> void main() { time_t now; struct tm *timenow; time(&now); //獲取unix時間戳 printf("now:%llu\n",now); timenow = localtime(&now); //將unix時間戳,轉化為本地時間 printf("Local time is %s/n",asctime(timenow)); //asctime函數把時間轉換成字符,通過printf()函數輸出 }