-
date
I have some troubles on working with dates. I can get the current date, and I can read in the date wanted into a char (string), but I am unable to calculate the difference between these two dates. I hope someone can help me.
Suggestions can always be sent to [email protected]
-
depends on what time functions you are using. If you are using time.h or ctime header files look up difftime(), which returns the number of seconds between two different times, which can they be translated into minutes, hours, days, weeks, years, decades, centuries; whatever, with a little tweaking.
-
I hope this isn't another... please answer my questions, but I will never be back so make sure that you email them to me... post.
What do you guys think?
-
no this isn't such a ...
Look, I'm sorry if you have a wrong impression of me, but I surely have no wrong intentions with this.
I am studying the C++ language, and my professors didn't know the answer eather. I'm already visiting this site since a year, and I admit, only now I have registered.
But this is not only to solve my own problems, if I can be of any help to one of you, you may always call on me, than I see what I can do about it.
-
There is a function in time.h or ctime to do what you want. It is called difftime(). Go look it up in your helpfiles. come back if you still cant manage with your attempt so that we can show you how to fix it.
oops unregistered has already told you about it.
-
fair enough, but posting questions/ideas/answers to the board helps more than one person at a time (potentially at least). Therefore many people don't send email responses and don't go to another site to look at code people are having problems with. You will get the most responses, for better or worse, by posting publically.
-
I'd use tm structs and mktime(). Then you can manipulate the information easily.
1. Get user date
2. Create a tm struct with the user's date
3. Use mktime() to fill in things for you (tm_yday specifically)
3. use localtime() to fill in a tm struct for the current date
4. Calculate the differences you need using the tm structs
HINT: for the difference in days look at tm_yday.
-
Your professor didn't know how to do this???? And he is a professor in what???