#include <stdio.h> #include <time.h> int main() {
time_t t; //时间戳 struct tm *p; time(&t); //获取时间戳 p=localtime(&t); //将时间戳转换为本地时间 printf("时间戳:%ld\n",t); printf("%d-%d-%d %d:%d:%d\n",(1900+p->tm_year),(1+p->tm_mon),p->tm_mday,p->tm_hour,p->tm_min,p->tm_sec); return 0; } ~
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/232035.html原文链接:https://javaforall.net
