#include<iostream>
#include<time.h>
int main()
{
// typedef __time64_t time_t;
// typedef __int64 __time64_t;
time_t ti = time(NULL);
std::cout << ti << std::endl;
/*
struct tm
{
int tm_sec; // seconds after the minute - [0, 60] including leap second
int tm_min; // minutes after the hour - [0, 59]
int tm_hour; // hours since midnight - [0, 23]
int tm_mday; // day of the month - [1, 31]
int tm_mon; // months since January - [0, 11] // 具体需要+1
int tm_year; // years since 1900 //具体需要+1900
int tm_wday; // days since Sunday - [0, 6]
int tm_yday; // days since January 1 - [0, 365]
int tm_isdst; // daylight savings time flag
};*/
tm* tm_time = localtime(&ti); //localtime将传进入的秒转化为结构体tm
char buf[128] = { 0 };
snprintf(buf, 128, "%4d/%02d/%02d %02d:%02d:%02d",
tm_time->tm_year + 1900,
tm_time->tm_mon+1,
tm_time->tm_mday,
tm_time->tm_hour,
tm_time->tm_min,
tm_time->tm_sec);
std::cout << buf << std::endl;
return 0;
}