C language - Time Format

#include <stdio.h> 
#include <time.h>
 int main () 
{ 
    time_t rawtime;       // time types (defined time.h) 
    struct (TM) * TimeInfo;      // time structure, time.h defined as follows: 
    int tm_sec ;
     int tm_min;
     int tm_hour;
     int tm_mday;
     int tm_mon;
     int tm_year;
     int tm_wday;
     int tm_yday;
     int tm_isdst; 
    time ( & rawtime); // get the time, in seconds, from January 1, 1970 starting, stored in rawtime 
    TimeInfo = localtime (& rawtime); //Local Switch, tm time structure
     // the asctime (TimeInfo); // into standard ASCII format Time: 
    the printf ( " of The Current DATE / Time IS:% S " , the asctime (TimeInfo));
     return  0 ; 
}

 #define BUFLEN 255
 #include<stdio.h>
 #include<time.h>
 int main()
 {  
    time_t t = time( 0 );
    char tmpBuf[BUFLEN];
     strftime(tmpBuf, BUFLEN, "%Y-%m-%d %H:%M:%S", localtime(&t)); //format date     and time. 
     printf("time is [%s]",tmpBuf);
    return 0;
}

Guess you like

Origin www.cnblogs.com/srx-0816/p/11529022.html