void DateTime(char const *date, char *buff) { int month, day, year; int hour, minute, second; static const char month_names[] = "JanFebMarAprMayJunJulAugSepOctNovDec"; sscanf(date, "%s %d %d %d:%d:%d", buff, &day, &year,&hour, &minute, &second); month = (strstr(month_names, buff)-month_names)/3+1; sprintf(buff, "%d%02d%02d%02d%02d%02d", year, month, day, hour, minute, second); //!Application Example //{ // #if 1 // #undef __TIME__ // #define __TIME__ "21:23:39" // #endif // 1 // char StrTime[32]; // int yy,mm,dd,hh,min,sec; // printf("\r\n " __DATE__ " " __TIME__ "\r\n"); // DateTime(__DATE__ " " __TIME__,StrTime); // printf(" StrTime:%s\r\n",StrTime); // sscanf(&StrTime[2], "%02d%02d%02d%02d%02d%02d", &yy,&mm,&dd,&hh,&min,&sec); // printf(" Times :%3d%3d%3d%3d%3d%3d\r\n",yy,mm,dd,hh,min,sec); //} }
log:
May 14 2017 21:23:39 StrTime:20170514212339 Times : 17 5 14 21 23 39 Process returned 0 (0x0) execution time : 0.022 s Press any key to continue.
沒有留言:
張貼留言
手機選擇帳號後,按下發布 要再點選一次發布哦