/*******************************************************************************/ /** *** 函 数 名: char *Time2String(const time_t timep, char *strDest) *** 功能描述: 将时间转换成国标格式的字符串 *** 全局变量: *** 输 入: const time_t timep :获得的时间 char *strDest:存储转换后的字符串 *** 输 出: 转换后的字符串地址 ******************************************************************************/ char *Time2String(const time_t timep, char *strDest) { char *address = strDest; // assert(strDest != NULL); struct tm* tm; time_t tempTime = timep; char *bars = (char *)"-",*colon = (char *)":", *space = (char *)" "; tm = localtime(&tempTime); tm->tm_year += 1900; tm->tm_mon += 1; sprintf(strDest, "%04d%s%02d%s%02d%s%02d%s%02d%s%02d", tm->tm_year, bars, tm->tm_mon, bars, tm->tm_mday, space, tm->tm_hour, colon, tm->tm_min, colon, tm->tm_sec); return address; }