📅  最后修改于: 2020-09-25 09:17:57             🧑  作者: Mango
在
char* asctime(const struct tm * time_ptr);
asctime() 函数将指向tm
对象的指针作为其参数,并以给定日历时间的形式返回文本表示形式:
Www Mmm dd hh:mm:ss yyyy
Type |
Description |
Obtained from |
Values |
---|---|---|---|
Www |
3 letter day of week |
|
Mon to Sun |
Mmm |
3 letter month name |
|
Jan to Dec |
dd |
2 digit day of month |
|
00 to 31 |
hh |
2 digit hour |
|
00 to 23 |
mm |
2 digit minute |
|
00 to 59 |
ss |
2 digit second |
|
00 to 59 |
yyyy |
4 digit year |
|
4 digit number |
#include
#include
using namespace std;
int main()
{
time_t curr_time;
time(&curr_time);
cout << "Current date and time: " << asctime(localtime(&curr_time));
return 0;
}
运行该程序时,输出为:
Current date and time: Tue Mar 21 13:52:57 2017