DWORD TimestampToSec(const char *pTimestamp)
{
TTime tTime;
char tmp;
sscanf(pTimestamp, "%04d-%02d-%02dT%02d:%02d:%02d.", &tTime.nYear, &tTime.nMonth, &tTime.nDay, &tTime.nHour, &tTime.nMinute, &tTime.nSecond);
return TimeToSeconds(tTime);
}
void main()
{
printf("secondes=%d\n" TimestampToSec("2019-03-01T09:30:08.230+0800"));
}
sscanf函数的强大之处在于,只需按照所需的格式就能够从字符串中提取对应的数据。