看代码:

#include <iostream>
using namespace std;

int main()
{
	time_t currentTime;
    time(¤tTime);
    struct tm *p;
    p = localtime(¤tTime);
    cout << p->tm_hour << endl;
    cout << p->tm_min << endl;
    cout << p->tm_sec << endl;

	return 0;
}
       结果:

20
1
7

       这就是20:01:07, 不多说。



本文转载:CSDN博客