#include
#include
int main(int argc, char * argv[])
{
// 得到标准时间秒数
time_t t_gm;
time(&t_gm);
// 标准时间转换到本地时间数字
tm tm_local;
localtime_s(&tm_local, &t_gm);
printf("本地时间:%04d-%02d-%02d:%02d.%02d.%02d\n", tm_local.tm_year+1900, tm_local.tm_mon+1, tm_local.tm_mday, tm_local.tm_hour, tm_local.tm_min, tm_local.tm_sec);
// 转换时间格式
tm tm_utc;
gmtime_s(&tm_utc, &t_gm);
printf("标准时间:%04d-%02d-%02d:%02d.%02d.%02d\n", tm_utc.tm_year+1900, tm_utc.tm_mon+1, tm_utc.tm_mday, tm_utc.tm_hour, tm_utc.tm_min, tm_utc.tm_sec);
// 把本地时间转换为标准时间, 将减去时区*3600秒
time_t t_local = mktime(&tm_utc);
int zone = ((t_gm-t_local)/3600);
printf("系统所在时区:%d\n", zone);
return 0;
}