博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C++获取当前时间(北京时间)
阅读量:2019 次
发布时间:2019-04-28

本文共 524 字,大约阅读时间需要 1 分钟。

C++获取当前时间

#include 
#include
using namespace std; int main( ){
time_t now = time(0); cout << "1970 到目前经过秒数:" << now << endl; tm *ltm = localtime(&now); cout << "年: "<< 1900 + ltm->tm_year << endl; cout << "月: "<< 1 + ltm->tm_mon<< endl; cout << "日: "<< ltm->tm_mday << endl; // 北京时区 + 8 int hour = (ltm->tm_hour + 8) % 24 ; cout << "时间: "<< hour << ":"; cout << ltm->tm_min << ":"; cout << ltm->tm_sec << endl;}
  • 输出如下:
1970 到目前经过秒数:1615886914年: 2021月: 3日: 16时间: 17:28:34

转载地址:http://pcmxf.baihongyu.com/

你可能感兴趣的文章
C#调用Python
查看>>
生活哲学
查看>>
C# using Sendkey function to send a key to another application
查看>>
日内交易策略
查看>>
WinForm触摸屏程序功能界面长时间不操作自动关闭回到主界面 z
查看>>
Async callback to awaitable Task<> z
查看>>
NESPER的大体结构 z
查看>>
bower的安装和使用
查看>>
solr4.x+tomcat+中文分词
查看>>
php与java通过socket通信demo
查看>>
mysql日期与long 类型换转
查看>>
jetty启动项目报无法找到org.springframework.web.context.ContextLoaderListener
查看>>
VMware Tools 的安装无法手动启动,自动安装正在进行中。
查看>>
C# Socket简单例子(服务器与客户端通信)【转】
查看>>
135行实现CRUD功能(PHP)
查看>>
Hibernate事务与并发问题处理(乐观锁与悲观锁)【转】
查看>>
Spring事务配置的五种方式【转】
查看>>
ant 入门
查看>>
maven 入门
查看>>
bootstrap资料收集
查看>>