The best solution would be to use your custom code, there are many built-in functions in php which can let you do it easily.
Date, strtotime and time.
- First convert any your dates from "Y-m-d H:i:s" format to Linux time-stamp using strtotime function.
- Make your calculations and use time to get current time-stamp if applicable.
- Convert you calculated time-stamp to dates using date function.