I am trying to convert a date in a specific format using strptime, and I realized that the AM / PM information is lost. I do not know why.
Here is the code.
struct tm t;
strptime("Wed 4/18/2007 4:28:22 PM", "%a %m/%d/%Y %H:%M:%S %p", &t);
std::cout<<t.tm_hour<<endl;
strptime("Wed 4/18/2007 4:28:22 AM", "%a %m/%d/%Y %H:%M:%S %p", &t);
std::cout<<t.tm_hour<<endl;
Can someone tell me why the specifier is needed %pin strptime?
Thanks in advance, AJ
source
share