std::time
Defined in header <ctime> | ? | ? |
---|---|---|
std::time_t time( std::time_t* arg ); | ? | ? |
返回当前日历时间,该时间编码为std::time_t
对象,并将其存储在arg
,除非arg
为空指针。
参数
arg | - | pointer to a std::time_t object to store the time, or a null pointer |
---|
返回值
当前日历时间编码为std::time_t
反对成功,(std::time_t)(-1)
关于错误。如果arg
,则返回值也存储在arg
...
注记
例
二次
#include <ctime>
#include <iostream>
int main()
{
std::time_t result = std::time(nullptr);
std::cout << std::asctime(std::localtime(&result))
<< result << " seconds since the Epoch\n";
}
二次
产出:
二次
Wed Sep 21 10:27:52 2011
1316615272 seconds since the Epoch
二次
另见
localtime | converts time since epoch to calendar time expressed as local time (function) |
---|---|
gmtime | converts time since epoch to calendar time expressed as Universal Coordinated Time (function) |
system_clock (C++11) | wall clock time from the system-wide realtime clock (class) |
c时间文件
? cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com