大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。
Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺
变量 | 类型 | 说明 | 范围 |
tm_sec | int | 每分钟的秒数 | [0 – 61] |
tm_min | int | 每小时后面的分钟数 | [0 – 59] |
tm_hour | int | 凌晨开始的小时数 | [0 – 23] |
tm_mday | int | 从每月份开始算的天数 | [1 – 31] |
tm_mon | int | 从一月份开始的月份数 | [0 – 11] |
tm_year | int | 从1900年开始的年数 | |
tm_wday | int | 从每周天开始算的天数 | [0 – 6] |
tm_yday | int | 一年的第几天,从零开始 | [0 – 365] |
tm_isdst | int | 夏令时 | |
四、源码及编译
current_time.cpp
#include <cstdio>
#include <ctime>
int main(int argc, char* argv[]) {
time_t rawtime;
struct tm *ptminfo;
time(&rawtime);
ptminfo = localtime(&rawtime);
printf("current: %02d-%02d-%02d %02d:%02d:%02d\n",
ptminfo->tm_year + 1900, ptminfo->tm_mon + 1, ptminfo->tm_mday,
ptminfo->tm_hour, ptminfo->tm_min, ptminfo->tm_sec);
return 0;
}
编译及运行
$ g++ current_time.cpp
$ ./a.out
current: 2017-07-26 23:32:46
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/189632.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...