Gamecommunity =GCHQ= http://forum.gamecommunity.co.uk:8080/ | |
date validation http://forum.gamecommunity.co.uk:8080/viewtopic.php?f=122&t=41292 |
Page 1 of 2 |
Author: | happyslappy [ Thu May 10, 2007 8:30 pm ] |
Post subject: | date validation |
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 |
Author: | Chadk [ Thu May 10, 2007 9:44 pm ] |
Post subject: | Re: date validation |
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? |
Author: | Lemon =GCHQ= [ Thu May 10, 2007 9:47 pm ] |
Post subject: | |
ooooooooooooo ding ding |
Author: | GeneralPublic=GCHQ= [ Thu May 10, 2007 10:16 pm ] |
Post subject: | Re: date validation |
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 |
Author: | Sleeper Service=GCHQ= [ Thu May 10, 2007 11:04 pm ] |
Post subject: | |
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 |
Author: | FoRcEFiRe [ Fri May 11, 2007 1:59 am ] |
Post subject: | |
lool |
Author: | happyslappy [ Fri May 11, 2007 9:16 am ] |
Post subject: | erm |
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 |
Author: | aim_x_here [ Fri May 11, 2007 9:21 am ] |
Post subject: | |
This is so we can filter out the under 20's from the forum So come on Chad, get helping! |
Author: | Arma [ Fri May 11, 2007 9:57 am ] |
Post subject: | |
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 |
Author: | Slayer=GCHQ= [ Fri May 11, 2007 10:34 am ] |
Post subject: | |
aim_x_here wrote: This is so we can filter out the under 20's from the forum
So come on Chad, get helping! Noooooooooo Does that mean me?? But what about the Pickle |
Author: | FoRcEFiRe [ Fri May 11, 2007 11:27 am ] |
Post subject: | |
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 |
Author: | Caspius=GCHQ= [ Fri May 11, 2007 11:49 am ] |
Post subject: | |
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.. |
Author: | Chadk [ Fri May 11, 2007 12:10 pm ] |
Post subject: | Re: erm |
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. |
Author: | happyslappy [ Sat May 12, 2007 6:05 pm ] |
Post subject: | durr |
yes but in a standard drop downs a user could still select 31 2 2008 thats my point |
Author: | happyslappy [ Sat May 12, 2007 6:14 pm ] |
Post subject: | ops |
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 |
Page 1 of 2 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |