Like this question , but there was no answer to my specific problem.
The current date is 2011-12-14, for reference, if this issue is considered in the future.
I tried this:
$maxAge = $row['maxAge']; // for example, $row['maxAge'] == 30 $cutoff = date('Ym-d', strtotime('-$maxAge days'));
And it returns the following value for $cutoff: 1969-12-31
And I tried this:
$maxAge = $row['maxAge']; // for example, $row['maxAge'] == 30 $cutoff = date('Ym-d', strtotime('-' . $maxAge . ' days'));
And it returns the following value for $cutoff: 2011-03-14
How to successfully pass this variable to the strtotime() function so that it calculates the number of days to subtract correctly?
For example, if $maxAge == 30 and the current date is 2011-12-14, then $cutoff should be 2011-11-14
Oneag source share