Login    Forum    Register    Search    Quick Links   

Board index » HELP AND ADVICE » G33K'S CORNER




Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: date validation
 Post Posted: Thu May 10, 2007 8:30 pm 
Offline
that was a stupid comment btw
User avatar

Joined: Wed Mar 03, 2004 12:40 pm
Posts: 109345
Location: manchester
anyone got out to do this on php - uk date format as well

i first though id take DMY format and convert them to unix epoch but for some reason it turns 31st feb into a date in july

all things lifted off net examples have been far to ott or not worked

also a reg ex for ip`s that works would be good whilst im at it as iv had issue on that as well

_________________
Image
Image


Top 
 Profile  
 
 Post subject: Re: date validation
 Post Posted: Thu May 10, 2007 9:44 pm 
Offline
Bow down to the master
User avatar

Joined: Thu Aug 12, 2004 12:59 pm
Posts: 1840
happyslappy wrote:

i first though id take DMY format and convert them to unix epoch but for some reason it turns 31st feb into a date in july


You do realise that theres only 28 days in feb? :)

_________________
Codito Ergo Sum | Even i, who have no clue about social life
Image


Top 
 Profile  
 
 Post subject:
 Post Posted: Thu May 10, 2007 9:47 pm 
Offline
an unsung hero!
User avatar

Joined: Tue Jun 29, 2004 1:13 am
Posts: 5852
Location: on the run from the boyz i love this city
ooooooooooooo ding ding :D

_________________
Image
"If your going to kill a man, it costs nothing to be polite."- Winston Churchill
three and a half foot long??? dude, it could have swallowed you whole! 3jorn=GCHQ=


Top 
 Profile  
 
 Post subject: Re: date validation
 Post Posted: Thu May 10, 2007 10:16 pm 
Offline
Saints ftw!!
User avatar

Joined: Fri Apr 23, 2004 6:22 pm
Posts: 7877
Location: /dev/null
Chadk=GCHQ= wrote:
happyslappy wrote:

i first though id take DMY format and convert them to unix epoch but for some reason it turns 31st feb into a date in july


You do realise that theres only 28 days in feb? :)


Not in Ricks world :twisted:

_________________
Insert unfunny comment here ->


Top 
 Profile  
 
 Post subject:
 Post Posted: Thu May 10, 2007 11:04 pm 
Offline
Humping a Super Model
User avatar

Joined: Mon Dec 27, 2004 1:54 pm
Posts: 3024
Location: NorLonTon
Good place for regular expressions not sure about the php dates q though

http://regexlib.com/Default.aspx


Expression:
^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$

Description: RegExp for validating the format of IP Addresses.
Matches: 127.0.0.1|||255.255.255.0|||192.168.0.1
Non-Matches: 1200.5.4.3|||abc.def.ghi.jkl|||255.foo.bar.1

_________________
Image


Top 
 Profile  
 
 Post subject:
 Post Posted: Fri May 11, 2007 1:59 am 
Offline
Great balls of fire
User avatar

Joined: Mon Mar 21, 2005 2:12 am
Posts: 756
Location: In the disco inferno
lool

_________________
Image
http://www.savenetradio.org


Top 
 Profile  
 
 Post subject: erm
 Post Posted: Fri May 11, 2007 9:16 am 
Offline
that was a stupid comment btw
User avatar

Joined: Wed Mar 03, 2004 12:40 pm
Posts: 109345
Location: manchester
Quote:
You do realise that theres only 28 days in feb?


thats my point durrrrr

but people will enter shit in forms so i need to validate it

_________________
Image
Image


Top 
 Profile  
 
 Post subject:
 Post Posted: Fri May 11, 2007 9:21 am 
Offline
The Librarian- OOK OOK!
User avatar

Joined: Mon Mar 08, 2004 12:42 am
Posts: 4658
Location: tree
This is so we can filter out the under 20's from the forum :P

So come on Chad, get helping!

_________________
Brother ANg-jung soon-um-bongo (Formerly Aim).
Image
Mostly Harmful.
Vive La France!
I want my sig back!


Top 
 Profile  
 
 Post subject:
 Post Posted: Fri May 11, 2007 9:57 am 
Offline
PFY wannabe
User avatar

Joined: Sun Jan 02, 2005 11:51 pm
Posts: 3295
Location: South, but not far south enough :/
This one looks ok : http://www.smartwebby.com/PHP/datevalidation.asp

I dont know php very well but with the example given I would do the overall check first, then do month then year, then validate the days so that you can test the days in the month correctly....

Sort of :
Code:
$month=substr($strdate,($pos+1),($pos));
$date=substr($strdate,0,($pos));
$year=substr($strdate,($pos+4),strlen($strdate));
}
if((($month=09)OR($month=04)OR($month=06)OR($month=11))AND(($date<=0)OR($date>30))){echo "30 days hath september, April June and November, Enter a Valid Date";}
{


If you get my meaning :)

_________________
Image

"I wish my lawn was emo, so it would cut itself...."


Top 
 Profile  
 
 Post subject:
 Post Posted: Fri May 11, 2007 10:34 am 
Offline
Coming out soon...

Joined: Mon Dec 26, 2005 12:13 am
Posts: 6680
Location: Wales
aim_x_here wrote:
This is so we can filter out the under 20's from the forum :P

So come on Chad, get helping!


Noooooooooo :(
Does that mean me?? :( :(
But what about the Pickle :(

_________________
Image
Quote:
- That boy NEEDS to look at porn, if only to try and fake being interested in women :D
- We could rename it to "slayers love life" but that was dead before it even started


Top 
 Profile  
 
 Post subject:
 Post Posted: Fri May 11, 2007 11:27 am 
Offline
Great balls of fire
User avatar

Joined: Mon Mar 21, 2005 2:12 am
Posts: 756
Location: In the disco inferno
slaps why not populate the forms with list boxes and let people select dates?

That way if someone selects feb, you can tell the other box to only have 28 values in it. This stops the need for validation as you do it before they even enter it :)

Box1 Month
Box2 Day
etc

_________________
Image
http://www.savenetradio.org


Top 
 Profile  
 
 Post subject:
 Post Posted: Fri May 11, 2007 11:49 am 
Offline
The Groundkeeper
User avatar

Joined: Fri Mar 26, 2004 7:59 pm
Posts: 6056
Location: UK
You tried this one?

http://www.vrooms.net/code.php?cat_select=PHP_Date_Validation&show=Date_Validation_and_Conversion

I expect you know all this, but I don't understand how you get the form data into variables on the php code.

Code:
  if ( $month==2 )
      {
         if ( $year % 4 != 0 )
            $dpm[2] = 28;
         else if ( $year % 400 == 0 )
            $dpm[2] = 29;
         else if ( $year % 100 == 0 )
            $dpm[2] = 28;
         else
            $dpm[2] = 29;
      }


I still don't understand how this works out whether it is a leap year. $dpm is the number of days in the month... I could do with sumat like this for a form I've got..

_________________
Image


Top 
 Profile  
 
 Post subject: Re: erm
 Post Posted: Fri May 11, 2007 12:10 pm 
Offline
Bow down to the master
User avatar

Joined: Thu Aug 12, 2004 12:59 pm
Posts: 1840
happyslappy wrote:
Quote:
You do realise that theres only 28 days in feb?


thats my point durrrrr

but people will enter shit in forms so i need to validate it

But validation isnt supposed to the the only kind of checking. Regex is to make sure that theres no bug that will eventually corrupt the data, and make it worth all shite.

You do NOT wannahave the user type in like 31-2-2007 in a clear text. But as pointed out, youd wanna use drop-down boxes.

_________________
Codito Ergo Sum | Even i, who have no clue about social life
Image


Top 
 Profile  
 
 Post subject: durr
 Post Posted: Sat May 12, 2007 6:05 pm 
Offline
that was a stupid comment btw
User avatar

Joined: Wed Mar 03, 2004 12:40 pm
Posts: 109345
Location: manchester
yes but in a standard drop downs a user could still select 31 2 2008

thats my point

_________________
Image
Image


Top 
 Profile  
 
 Post subject: ops
 Post Posted: Sat May 12, 2007 6:14 pm 
Offline
that was a stupid comment btw
User avatar

Joined: Wed Mar 03, 2004 12:40 pm
Posts: 109345
Location: manchester
Quote:
slaps why not populate the forms with list boxes and let people select dates?

That way if someone selects feb, you can tell the other box to only have 28 values in it. This stops the need for validation as you do it before they even enter it

Box1 Month
Box2 Day


thats the day its done soz forcey i didnt see that, but due to having to stick to uk date format i cant see how, other wise it would be easy with php / sessions and dynamically change the days in the form

chadk / slayer please stay out of this thread with your smarty arse comments that mean nothing

again a big thank you to everyone else in here who has tried to be constuctive

_________________
Image
Image


Top 
 Profile  
 
Display posts from previous:  Sort by  
 
Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next

Board index » HELP AND ADVICE » G33K'S CORNER


Who is online

Users browsing this forum: No registered users and 0 guests

 
 

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
  • Shoutbox
  • Shout Message



cron