C++ 获取凌晨/月初 时间戳

时间:2022-11-01 02:18:40



static unsigned long long getMonthTime() {
        time_t t = time(0);   // get time now
        struct tm * zeroTm= localtime(&t);
        zeroTm->tm_hour = 0;
        zeroTm->tm_min = 0;
        zeroTm->tm_sec = 0;
        zeroTm->tm_mday = 0;
        unsigned long long zeroTime = mktime(zeroTm);
        return zeroTime*1000;
    }
    
    static unsigned long long getMorningTime() {

        time_t t = time(0);   // get time now
        struct tm * zeroTm= localtime(&t);
        zeroTm->tm_hour = 0;
        zeroTm->tm_min = 0;
        zeroTm->tm_sec = 0;
        unsigned long long zeroTime = mktime(zeroTm);
        return zeroTime*1000;
    }