[C++] 有关时间的操作方法


显示时间

#include <time.h>
#include 
<stdio.h>

main()
{
    
struct tm *tm_ptr;
    time_t the_time;
    (
void) time(&the_time);

    tm_ptr 
= localtime(&the_time);

    printf(
"Raw time is %ldn", the_time);
    printf(
"MyTime show:n");
    printf(
"Date:%02d/%02d/%02d"
           tm_ptr
->tm_year,
           tm_ptr
->tm_mon+1,
           tm_ptr
->tm_mday);

    exit(
0);
}


原文地址:https://www.cnblogs.com/xuzhong/p/385647.html