Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in C only
Search
Advanced Search
Forums
BYTES
Product Launch
Updates
Developer Toolkit
Today's Posts
Member List
Calendar
Home
Forum
Topic
C
How do you get a previous date in C++?
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
Alex T
New Member
Join Date:
Oct 2010
Posts:
29
#1
How do you get a previous date in C++?
Oct 24 '10, 12:05 AM
If you have the current date, how do you get the date 1 day or 2 days or 100 days back?
weaknessforcats
Recognized Expert
Expert
Join Date:
Mar 2007
Posts:
9214
#2
Oct 24 '10, 04:05 PM
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.
Comment
Post
Cancel
donbock
Recognized Expert
Top Contributor
Join Date:
Mar 2008
Posts:
2427
#3
Oct 24 '10, 06:30 PM
Take a look at
mktime
(in time.h).
Comment
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Comment