Re: No is_date() function?
| From: | Nathan Nobbe | Date: | Fri, 27 Jul 2007 13:01:33 +0000 |
| Subject: | Re: No is_date() function? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-259667@lists.php.net to get a copy of this message | ||
> On 7/27/07, Richard Lynch <ceo@l-i-e.com> wrote:
> 2) Some fancy OOP object (use OOP isa function)
basically what i suggested in my initial reply; build a couple
of custom wrapper objects around the stock php date / time
functions.
is_a is a relic from php4 that has been deprecated; go for
the instanceof operator.
http://us3.php.net/manual/en/function.is-a.php
-nathan
On 7/27/07, Richard Lynch <ceo@l-i-e.com> wrote:
>
> On Wed, July 25, 2007 8:55 am, Ken Tozier wrote:
> > I wrote a serialization function to turn arbitrary PHP variables into
> > Macintosh plist compatible XML but see that there is no "is_date"
> > tester as there is for bool, object, array etc. Is there a relatively
> > simple (and robust) way to detect if a variable is a date? For
> > example:
> >
> > $person = array('name'=>'bob',
> > 'sex'=>'male', 'date_of_birth'=>
> > $someDateHere);
>
> PHP has no 'date' type...
>
> So what you are calling a date is one of these:
> 1) An integer representing Unix timestamp (is_int())
> 2) Some fancy OOP object (use OOP isa function)
> 3) A string that happens to look like a date to humans
> a) strtotime might work
> b) a preg_match might work better
>
> --
> Some people have a "gift" link here.
> Know what I want?
> I want you to buy a CD from some indie artist.
> http://cdbaby.com/browse/from/lynch
> Yeah, I get a buck. So?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>