c++ vs中如何操作时间
这篇文章主要介绍“c++ vs中如何操作时间”,在日常操作中,相信很多人在c++ vs中如何操作时间问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”c++ vs中如何操作时间”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
代码如下:
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
cout << "Hello World!" << endl;
const time_t now = time(NULL);
cout << "时间戳:" << now << endl;
struct tm systime;
localtime_s(&systime, &now);
// 输出 tm 结构的各个组成部分
cout << "年: " << 1900 + systime.tm_year << endl;
cout << "月: " << 1 + systime.tm_mon << endl;
cout << "日: " << systime.tm_mday << endl;
cout << "时间: " << systime.tm_hour << ":" << systime.tm_min << ":" << systime.tm_sec << endl;
}
结果:
Hello World!
时间戳:1649294557
年: 2022
月: 4
日: 7
时间: 9:22:37
相关内容
这些是最新的
热门排行
- THINKPHP5+GatewayWorker+Workerman 开发在线客服系统
- 在手机浏览器网页中点击链接跳转到微信界面的方法
- 尊云网站目录系统 ThinkPHP5网站分类目录程序 v2.2.221011
- CentOS 7安装shadowsock(一键安装脚本)
- AdminTemplate 基于LayUI 2.4.5实现的网站后台管理模板
- 用NW.js(node-webkit)开发多平台的桌面客户端
- PHP生成随机昵称/用户名
- THINKPHP5网站分类目录程序 尊云网站目录系统
- 织梦(DEDECMS)微信支付接口 微信插件
- 基于LayUI开发的 网站后台管理模板 BeginnerAdmin
- 响应式后台网站模板 - AMA.ADMIN
- layuiAdmin后台管理模板 Iframe版
- LayUI 1.0.9 升级 至 LayUI 2.1.4 方法
- 简洁清爽的会员中心模板
- jQuery幸运大转盘抽奖活动代码