ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
To expand on the above, the basic procedure involves first converting both dates to epoch seconds. This makes it possible to simply subtract one date from the other to get the difference in seconds. After that it's just simple arithmetic to convert that into the number of days.
The gnu date command has a -d option for converting an arbitrary date into any supported format, so start there.
BTW, just as an aside, if you search the web you're likely to find ready-made solutions to this problem already available. You don't think you're the first person to ever need to calculate the difference between two dates, do you?