C & C ++ function of time and the time class

C language function of time and the localtime function

#pragma warning (disable: 4996) // disable error C4996 

#include <time.h>
 int main () { 
    time_t T = Time (NULL); // get the current time handle, time_t is Int64 
    (TM) * the ptime = localtime (& T ); // time the handle is converted to the time structure tm, localtime former function may report error C4996 
    / * use the localtime_s () 
    (TM) time; 
    the localtime_s (& time, & T); 
    (TM) * the ptime = & time; 
    * / 
    int nYear = ptime-> tm_year + 1900 ;
     int nMonth = ptime-> tm_mon + . 1 ;
     int nday = ptime-> tm_mday;
     int nHour = ptime->tm_hour;
    int nMinute = ptime->tm_min;
    int nSecond = ptime->tm_sec;
    printf("%d-%02d-%02d %02d:%02d:%02d", nYear, nMonth, nDay, nHour, nMinute, nSecond);

    return 0;
}

 

Guess you like

Origin www.cnblogs.com/htj10/p/11518519.html