Ron Piggott (PHP) wrote:
I have used the strtotime command to calculate a week ago (among other
things) with syntax like this:
$one_week_ago = strtotime("-7 days");
$one_week_ago = date('Y-m-d', $one_week_ago);
How would you use this command to figure out the last day of the month
in two months from now --- Today is October 24th 2006; the results I am
trying to generate are December 31st 2006. I want to keep the same
result until the end of October and then on November 1st and throughout
November the result to be January 31st 2007
Not great but you could do:
$two_months = strtotime("+2 months");
// get the bits you need for mktime
$num_of_days = date('t', $two_months);
$month = date('n', $two_months);
$year = date('Y', $two_months);
$last_day = mktime(0, 0, 1, $month, $num_of_days, $year);
echo 'date: ' . date('r', $last_day);
--
Postgresql & php tutorials
http://www.designmagick.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php