Link to home
Start Free TrialLog in
Avatar of Ching Tello
Ching TelloFlag for United States of America

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
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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()'
Avatar of Ching Tello

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(time(NULL)));