I need to compare current date against a starting date, idea being that on every month + 1 day it will return as if only one month has gone by. So if starting date is 2014-10-27, on 2014-11-27 it will still show Less than a month ago, and on 2014-11-28 it'll show more than a month ago.
Currently I have:
$start_datetime = '2014-10-27';
// true if my_date is more than a month ago
if (strtotime($start_datetime) < strtotime('1 month ago')){
echo ("More than a month ago...");
} else {
echo ("Less than a month ago...");
}
DateTime is best suited for date math in PHP. DateTime objects are comparable which makes this very readable, too.
For PHP versions older than 5.5 you need to clone
$startDate
for this to work: