Re: checking date is not greater than today
| From: | Peter J. Schoenster | Date: | Mon, 01 Jul 2002 05:19:42 +0000 |
| Subject: | Re: checking date is not greater than today | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-104627@lists.php.net to get a copy of this message | ||
On 30 Jun 2002 at 22:31, Timothy J. Luoma wrote:
>
> I am trying to compare a given date string (i.e. June 30, 2002 is
> 20020630). I want to make sure that the input string that is given is
> not greater than today (i.e. if today is June 30, and you ask for
> 20020701, I want to be able to throw an error).
> I'm a newbie, so I'm not sure the best way to do this. My thought was
> that if I take the year (YYYY) and add on the day-of-year (i.e. Feb 10
> = 041) then I would be able to compare them as you would any other
> numbers.
[...] snipped
I ignored the rest as it was beyond me. I'm also a newbie to PHP but I looked into dates in
Perl. I quickly began using a module from CPAN as I realized this was more complicated than meets
the eye
and you seem to indcate that when you mention leap years.
I would question why you accept input as a particular format. It's certainly easier to work
with timestamps than arbitrary representations of dates. I would not be so quick to assume you have
to accept
input as is. Or at least have it fixed to a format ... but the Perl modules I've worked with
are liberal with what they receive .... :) Anyhow, I'd just find a PHP module ot handle this.
I found this:
http://www.phpbuilder.com/columns/akent20000610.php3
but I'd just want a class (guess you call it that in PHP).
And then this looks real interesting:
> Date/Time Processing with PHP
> By The Disenchanted Developer
> March 19, 2002
http://zope1.devshed.com/zope.devshed.com/Server_Side/PHP/DateTime/page1.html
In Perl I happen to use this moduel for date manipulation:
http://search.cpan.org/doc/STBEY/Date-Calc-5.0/Calc.pod
There must be something similar in PHP but since I too am a newbie (and lazy to boot) I don't
know what it is.
Peter