#include <string.h>
#include <time.h>
int main() {
struct tm t;
char str[80];
t.tm_sec=0;
t.tm_min=10;
t.tm_hour=14;
t.tm_mday=1;
t.tm_mon=9;
t.tm_year=114;
t.tm_wday=4;
t.tm_yday=0;
t.tm_isdst=0;
int utime = mktime(&t);
strcpy(str,asctime(&t));
printf("%s: %d",str, utime);
return 0;
}
int main()
{
struct tm *p;
time_t timep;
timep=time(NULL);
p = localtime(&timep);
printf("%d/%d/%d \t" ,(1900+p->tm_year),(1+p->tm_mon),p->tm_mday);
printf("%d:%d:%d %d \t",(p->tm_hour+8),p->tm_min,p->tm_sec,365-(p->tm_yday));
}
time_t time(time_t *timer);
double difftime(time_t time1,time_t time2); //得到時間差
struct tm *gmtime(const time_t *timer); //把日曆時間轉換成國際時間
struct tm *localtime(const time_t *timer); //轉成UTC時間,和北京時間相差8小時
char *asctime(const struct tm *timeptr); /將時間和日期以字符串格式表示
char *ctime(const time_t *timer); //得到字符串表示的時間
size_t strftime(char *s,size_t maxsize,const char *format,const struct tm *timeptr); //設定指定格式的時間
time_t mktime(struct tm *timeptr); //設置時間
clock_t clock(void) //得到處理器時間
http://cpp.sh/