Re: Check a date
| From: | Shaun | Date: | Wed, 30 Apr 2003 12:04:54 +0000 |
| Subject: | Re: Check a date | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-145764@lists.php.net to get a copy of this message | ||
Rolf,
I have modifeid the function slightly so that it returns '-2' if the date is
at all invalid
<?php
function futureDate($timestamp){
$t = split("/",$timestamp);
if (count($t)!=3) $t = split("-",$timestamp);
if (count($t)!=3) $t = split(" ",$timestamp);
if (count($t)!=3) return -2;
if (!is_numeric($t[0])) return -2;
if (!is_numeric($t[1])) return -2;
if (!is_numeric($t[2])) return -2;
if ($t[0]<1902 || $t[0]>2037) return -2;
$timeStamp = mktime(0,0,0, $t[1], $t[2], $t[0]);
if($timeStamp >= time()){
return true;
} else {
return false;
}
}
?>
but when i use if(futureDate($_POST[booking_date]) == '-2'){
it always returns true, can you see why this is happening?
Thanks for your time
"Rolf Brusletto" <rolf-list@triculture.com> wrote in message
news:3EAF0562.6080103@triculture.com...
> *This message was transferred with a trial version of CommuniGate(tm) Pro*
> Shaun -
>
> If the function returns -1 it means the year was not numeric
> If the function returns -2 it means the month was not numeric
> If the function returns -3 it means the day was not numeric
>
> Rolf Brusletto
> PHP / MySQL Coder
> http://www.phpexamples.net
>
>
>
>
> shaun wrote:
>
> >*This message was transferred with a trial version of CommuniGate(tm)
Pro*
> >Rolf,
> >
> >What does it mean if the funtion returns -1, -2 or -3?
> >
> >Thanks for your help
> >
> >
> >"Shaun" <shaun@mania.plus.com> wrote in message
> >news:20030429215108.95317.qmail@pb1.pair.com...
> >
> >
> >>Thank you Rolf, thats a great function!
> >>
> >>"Rolf Brusletto" <rolf-list@triculture.com> wrote in message
> >>news:3EAEF979.30207@triculture.com...
> >>
> >>
> >>>*This message was transferred with a trial version of CommuniGate(tm)
> >>>
> >>>
> >Pro*
> >
> >
> >>>Shaun: heres a snippet that will work... just written and tested, I
will
> >>>need it in the future anyways!
> >>>
> >>>http://www.phpexamples.net/codeExSnippet-38.html
> >>>
> >>>Rolf Brusletto
> >>>PHP / MySQL Coder
> >>>http://www.phpexamples.net
> >>>
> >>>
> >>>
> >>>shaun wrote:
> >>>
> >>>
> >>>
> >>>>*This message was transferred with a trial version of CommuniGate(tm)
> >>>>
> >>>>
> >>Pro*
> >>
> >>
> >>>>the date format would be YYYY-MM-DD
> >>>>
> >>>>
> >>>>"Rolf Brusletto" <rolf-list@triculture.com> wrote in message
> >>>>news:3EAEEDB6.60408@triculture.com...
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>>*This message was transferred with a trial version of CommuniGate(tm)
> >>>>>
> >>>>>
> >>Pro*
> >>
> >>
> >>>>>shaun - what format is the date in?
> >>>>>
> >>>>>Rolf Brusletto
> >>>>>PHP / MySQL Coder
> >>>>>http://www.phpexamples.net
> >>>>>
> >>>>>shaun wrote:
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>>*This message was transferred with a trial version of
CommuniGate(tm)
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>Pro*
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>>>Hi,
> >>>>>>
> >>>>>>How can i check whether a given date occurs before today?
> >>>>>>
> >>>>>>Thanks for your help
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>
> >>
> >
> >
> >
> >
> >
>