c++获取时间

time_t rawtime;
    time(&rawtime);
    long now = rawtime;
    printf("时间戳:%ld",now);
    
     struct tm *ptm = localtime((time_t*)&now);
    char tmp[100] = {0};
    memset(tmp, 0x0, 100);
    strftime(tmp, sizeof(tmp), "%Y-%m-%d %H:%M:%S", ptm);
    printf("%s",tmp);

 

你可能感兴趣的:(C++)