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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Alex T
    New Member
    • Oct 2010
    • 29

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

    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
    • Mar 2007
    • 9214

    #2
    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

    • donbock
      Recognized Expert Top Contributor
      • Mar 2008
      • 2427

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

      Comment

      Working...