How about - and a little more complex ...
$mydate = date("d")!=1 && date("d",strtotime("+1 month"))==1 ?
date("Y-m-d",strtotime("+1 month")-86400) : date("Y-m-d",strtotime("+1
month"));
to summarise - if you perform your "+1 month" and it creates a day of 1, but
the current day isn't 1 - do the same calculation, but a day less ...
otherwise - do the month more. I haven't tested it - but it should give the
results you want.
-----Original Message-----
From: 1LT John W. Holmes [mailto:holmes072000@;charter.net]
Sent: 31 October 2002 17:10
To: Jeff Bearer; [EMAIL PROTECTED]
Subject: Re: [PHP] strtotime bug? end of the month.
> date("Y-m-d",strtotime("+1 month"))
>
> returns December 1st! This happens when you add 1 month to any day that
> doesn't exist in the next month. Quite annoying that you have to handle
> it like this:
>
> date("Y-m-d",strtotime("+1 month",strtotime(date("Y-m-1"))))
How about
echo date('y-m-d',strtotime('next month last day'));
---John Holmes...
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
_____________________________________________________________________
This message has been checked for all known viruses by the
MessageLabs Virus Control Centre.
This message has been checked for all known viruses by the MessageLabs Virus Control
Centre.
*********************************************************************
Notice: This email is confidential and may contain copyright material of Ocado
Limited (the "Company"). Opinions and views expressed in this message may not
necessarily reflect the opinions and views of the Company.
If you are not the intended recipient, please notify us immediately and delete all
copies of this message. Please note that it is your responsibility to scan this
message for viruses.
Company reg. no. 3875000. Swallowdale Lane, Hemel Hempstead HP2 7PY
*********************************************************************
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php