This is a discussion on Re: A "bad" Unix Timestamp? within the PHP Language forums, part of the PHP Programming Forums category; Warren Oates wrote: <snip> > That's all fine. Then I think, well, it would be nice if ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Warren Oates wrote:
<snip> > That's all fine. Then I think, well, it would be nice if I could tell > the user something like "there's not that may days in $m" and I should > be able to use strtotime() and date() -- but it turns out (and rightly > so) that you can't create a "bad" Unix timestamp. > > For instance, > > 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)); > > I can write a switch, of course, and there's only 5 cases (30 days > hath September etc., plus February needs to be dealt with). It > intrigues me, though, and I wondered if anyone else had played with it. Something like this? <?php $user_date = '2004-09-31'; if (date('Y-m-d', strtotime($user_date)) != $user_date) {/* bad date */} ?> -- USENET would be a better place if everybody read: http://www.expita.com/nomime.html http://www.netmeister.org/news/learn2quote2.html http://www.catb.org/~esr/faqs/smart-questions.html |