Avatar of Ching Tello
Ching Tello
Flag 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++?
C++

Avatar of undefined
Last Comment
Ching Tello

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
jkr

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
jkr

Sorry, it is possible to determine whether it is DST or not, but the means are a bit over the top.
jkr

Oh, another side note, if you use a 'std::string' instead, the 'compare()' member will return the same results as 'strcmp()'
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)));
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes