Re: strtotime

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear Ron:

I have a solution as follows:

$date=("2006-10-26");
$date=strtotime($date);
$date=date('Y-m-1',$date);
$now=strtotime("+3 month", strtotime($date));
$lastday=strtotime("-1 day", $now);
echo date('Y-m-d',$lastday);
//2006-12-31

It's a very easy way to do you want.
I use strtotime to convert date to the first day of this month.
And, add 3 months to the day and subtract 1 day.
Then, you can get the day you want.

Regads,

----
Brad

On 10/25/06, Ron Piggott (PHP) <ron.php@xxxxxxxxxxxxxxxxxx> 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

Ron



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux