This is a discussion on Re: A "bad" Unix Timestamp? within the PHP Language forums, part of the PHP Programming Forums category; On Wed, 20 Oct 2004, Warren Oates wrote: > it turns out (and rightly so) that you can't create ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
On Wed, 20 Oct 2004, Warren Oates wrote:
> it turns out (and rightly so) that you can't create a "bad" Unix > timestamp. > > date ("F d Y",strtotime("2004-09-31")); > > will return October 01 2004 and fwiw, so will > > date ("F d Y",mktime(0,0,0,9,31,2004)); Rightly or wrongly, I personally have found this quite a useful "feature". It means you can *always* calculate the last date in the current month: mktime(0, 0, 0, date("m") + 1, 0, date("Y")) or tomorrow: mktime(0, 0, 0, date("m"), date("d") + 1, date("Y")) This latter is nicer than time() + 86400 because that doesn't always seem to return exactly midnight. So in your example, you could determine if the user has entered 31 in a month with only 30 days with: if (date("d", mktime(0,0,0,$m+1,0,$y)) < $d) { // not that many days in the selected month } Of course this assumes a valid $m and $y. -- Matt |