About
Pricing
Community
Teams
Start Free Trial
Log in
Ching Tello
asked on
3/13/2012
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++
4
1
Last Comment
Ching Tello
8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
jkr
3/13/2012
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
3/13/2012
Sorry, it is possible to determine whether it is DST or not, but the means are a bit over the top.
jkr
3/13/2012
Oh, another side note, if you use a 'std::string' instead, the 'compare()' member will return the same results as 'strcmp()'
Ching Tello
3/14/2012
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))
);
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