如何在C ++中获取当前时间和日期? [英] How to get current time and date in C++?

查看:472
本文介绍了如何在C ++中获取当前时间和日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解决方案

std C库提供了一个跨平台的方法来获取当前日期和时间在C ++中? a href =http://en.cppreference.com/w/cpp/chrono/c/time =noreferrer> time()
这是从时代开始的秒数,可以使用标准C函数转换为日期和 H:M:S Boost 还有时间/日期库,你可以检查。

  time_t timev; 
时间(& timev);


Is there a cross-platform way to get the current date and time in C++?

解决方案

std C libraries provide time(). This is seconds from the epoch and can be converted to date and H:M:S using standard C functions. Boost also has a time/date library that you can check.

time_t  timev;
time(&timev);

这篇关于如何在C ++中获取当前时间和日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆