logs archiveIRC Archive / Freenode / #php / 2015 / August / 23 / 1
Sagar
Hello, i am trying the dob validate regex: http://pastebin.com/s6VBNSFk
It gives an error: ( ! ) Warning: preg_match(): Unknown modifier '(' in
__adrian
likecolacola http://viper-7.com/g1iL7p
Sagar, don't do this
why??
just check that it is a valid date.
Sagar
__adrian: how?
I want to set the validate format dd/mm/yyyy
how can i easily do that without regex?
__adrian
IF it's a dob for someone who is expected to be alive, then also check that it is a date between now and (e.g.) a hundred years ago
a) why does the format matter? b) split on "/" and then validate each segment
but I would recommend using DateTime
likecolacola
__adrian: thanks, i will read it now... what i found is that file() brings a new line (a0 in binary) to my string...
Sagar
_adrian, i am trying to test the $_post dob
$_post['DOB'] should match the regex or format dd/mm/yyyy
likecolacola
colacola: 636f6c61636f6c61, and colacola+\n: 636f6c61636f6c610a
sorabji
Sagar: just pass it to DateTime
__adrian
likecolacola http://php.net/file  read about $flags
         

Bittarman
DateTime::createFromFormat($_POST['DOB'], 'd/m/Y')
__adrian
^- there
Sagar
Bittarman: how to validate it?
if(!DateTime::createFromFormat($_POST['DOB'], 'd/m/Y')) { echo "Invalid format"; }
would that work?
__adrian
i wouldn't say "invalid format"
it might be a bad format, or a bad date
Bittarman
Sagar, false ===
Sagar
Bitterman: can u tell me the exactly syntax to validate?
__adrian
Ô_Ô
runinsquares
my arms hurt :( 20kg in my backpack, 20kg each arm and had to carry it 20 mins from the supermarket ._.
Sagar
or u mean this? if(DateTime::createFromFormat($dob, 'd/m/Y') === false) {
Bittarman
that.
sugar
Sagar
that's what i want to do?
Bittarman
yes
Sagar
not working
i post
23/08/1984
it still says Invalid date of birth.
if(DateTime::createFromFormat($dob, 'd/m/Y') === false) { echo "Invalid date of birth."; exit(); }
runinsquares
what's in $dob?
Sagar
$dob = 23/08/1984
runinsquares
there's your problem
Sagar
?
Bittarman
sugar, wrong order for the arguments, I do apologise.
format, then input
__adrian
Bittarman
__adrian, division by zero...
         

__adrian
yes
Bittarman
you need quotes ;)
__adrian
my point exactly.
Sagar
Bittarman: can u please help how?
Bittarman
Sagar, you need help swapping the order of the format and input?
likecolacola
__adrian: thanks again
* 100
Bittarman
runinsquares
you moved yet __adrian?
Bittarman
like I said, I got the parameters in the wrong order, swap them around
format first, then the input.
Sagar
this is what i am trying to do
http://pastebin.com/tf1F6SDk
but it still says invalid bday
sorabji
swap the parameters
runinsquares
if(DateTime::createFromFormat('d/m/Y',$dob) === false) {
__adrian
Sagar sorry didn't see the wrong param order
sorabji
who can remember these things
Sagar
runinsquares: thanks :)
__adrian
^-- & Bittarman
Sagar
thanks everyone
^_^
runinsquares
Sagar, i did nothing special, Bittarman did all the work
sorabji
they should put all the information somewhere that's easy to look up when you can't remember
__adrian
mm. indeed.
Bittarman
they could call it the documatron 9000
__adrian
runinsquares partially moved
Sagar
Bittarman thank u as well :)
I do said thanks everyone :)
sorabji
it needs to be over 9000 though
runinsquares
__adrian, so you're in cali(?) living out of boxes before you move to indiana, to live out of boxes? :p
Bittarman
over 9000? theres no way that can be right!
__adrian
no... i'm in michigan, living ouot of hotels, while the boxes are in Cali and the house in Indiana hasn't been bought yet
*out
runinsquares
http://www.dizzyfrinks.com/kicos/ this stuff is tasty D:
__adrian
other than that everything is fantastic </not-sarcasm>
runinsquares
__adrian, why michigan?
__adrian
that's where the new job is. i'm on-site for a while before going remote.
runinsquares
ooh
the important question is where are you pooping
(don't have to answer)
in fact, don't answer :P
please
__adrian
not the woods :)
runinsquares
\o,
pthreat
__adrian: He wants you to leave those logs there for him to inspect, he wants to see what you've done
runinsquares
so you're about the distance from london to newcastle from home
__adrian
the logs have been sanitized
runinsquares um... ok
runinsquares
pthreat, i'll bring david attenbrough
__adrian, i'm not good with US distances, so that's my conversion so i understand it
pthreat
__adrian: through bill gates wonder-turn-sh*t-into-water-maching I guess ?
« prev 1 2 3 4 5 6 7 8 9 10 11 12 next »