By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 852 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

How do you get a previous date in C++?

P: 29
If you have the current date, how do you get the date 1 day or 2 days or 100 days back?
Oct 24 '10 #1

✓ answered by donbock

Take a look at mktime (in time.h).

Share this Question
Share on Google+
2 Replies

Expert Mod 5K+
P: 9,197
You use Julian days.

Pick a start date, like 1/1/2000 and calculate the number of days from then to your date. That will be the Julian day.

Then just subtract 100 days aand convert that result Julian date back to a calendar date.
Oct 24 '10 #2

Expert 100+
P: 2,396
Take a look at mktime (in time.h).
Oct 24 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.