`

c++获取时间

    博客分类:
  • 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);

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics