How Do I Parse a Date Time String That Includes Fractional Time?
问题 I have a date time string: 20:48:01.469 UTC MAR 31 2016 I would like to convert this string representation of time to a struct tm using strptime , but my format string isn't working. Is there a format specifier for fractional seconds? Perhaps %S , %s , or something else? Code snippet is below: tm tmbuf; const char *str = "20:48:01.469 UTC MAR 31 2016" const char *fmt = "%H:%M:%s %Z %b %d %Y"; strptime(str,fmt,&tmbuf); 回答1: Using this free, open source C++11/14 library, here is another way to