Ching Tello
asked on
C++ compare timestamp in string format
I have a string in this format YYYYMMDDhhmmss, how to compare this string with current time in C++?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry, it is possible to determine whether it is DST or not, but the means are a bit over the top.
Oh, another side note, if you use a 'std::string' instead, the 'compare()' member will return the same results as 'strcmp()'
ASKER
Thanks to jkr for the simple solution. I originally used difftime() for comparison which is more complex.
It works. You will need to add a parameter for strftime() because this function doesn't allow 3 parameters.
strftime(acCurTime,14, "%Y%m%d%H%M%S",localtime(t ime(NULL)) );
It works. You will need to add a parameter for strftime() because this function doesn't allow 3 parameters.
strftime(acCurTime,14, "%Y%m%d%H%M%S",localtime(t