You are here: Re: Options for Validating a Date Value? « PHP Programming Language « IT news, forums, messages
Re: Options for Validating a Date Value?

Posted by Acrobatic on 11/24/07 21:16

What about first converting the integer to a date using the "date"
function. From here you can see if it validates to a real date by
using PHP's built-in "checkdate" function, and then go from there. You
will have to do additional testing if the converted integer from the
first step turns out to be "12-31-1969," as most numbers 5-digits or
less will.

ie

date('m-d-Y',12345) returns "12-31-1969"




On Nov 24, 2:56 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> Rob Wilkerson wrote:
> > Surprisingly (at least to me), there doesn't seem to be a built-in
> > function to validate a date value (like, say, is_date()). Given that,
> > is there a best practice for determining whether a value is a valid
> > date/time? The values I need to test will likely be unix timestamp
> > values and I need to be able to distinguish them as date/time values
> > from other integer/numeric values.
>
> > What I'm trying to do is use reflection to iterate over the properties
> > of an object and insert them into database fields based on their type
> > (integers in an INT field, strings in a VARCHAR field, date/time
> > values in a DATETIME field). Most are fairly straightforward, but I'm
> > not sure how to consistently and accurately identify a datetime value.
>
> > Any thoughts would be appreciated.
>
> > Rob
>
> Unix timestamps are just integers. You can't differentiate them.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация