要用到, 记录一下:

#include <iostream>
using namespace std;

unsigned int getMorningTime() 
{  
    time_t t = time(NULL); 
    struct tm * tm= localtime(&t);  
    tm->tm_hour = 0;  
    tm->tm_min = 0;  
    tm->tm_sec = 0;  
    return  mktime(tm);  
}  

int main()
{
	cout << getMorningTime() << endl;
	return 0;
}
       结果:1509638400

    

      查了一下, 刚好就是今天凌晨零点零时零分的时间戳。


      不多说。


本文转载:CSDN博客