Re: [PHP] Re: Date validation

2011-05-23 Thread Andrew Ballard
On Mon, May 23, 2011 at 9:55 AM, Tamara Temple wrote: > Isn't this typically why date selectors are used on the front end? > Not really. Date selectors are intended to make data entry easier on the front end while allowing only valid date selections, but you can't really rely on them. * Most dat

Re: [PHP] Re: Date validation

2011-05-23 Thread Tamara Temple
Isn't this typically why date selectors are used on the front end? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Re: Date validation

2011-05-23 Thread Pete Ford
On 23/05/11 13:12, tedd wrote: At 9:47 AM +0100 5/23/11, Pete Ford wrote: Finally, for some applications I have made an AJAX (javascript + PHP) implementation which provides feedback to the user as they type in the date field: every time a character is typed in the box, the backend is asked to p

[PHP] Re: Date validation

2011-05-23 Thread tedd
At 9:47 AM +0100 5/23/11, Pete Ford wrote: Finally, for some applications I have made an AJAX (javascript + PHP) implementation which provides feedback to the user as they type in the date field: every time a character is typed in the box, the backend is asked to parse it and then format it in

[PHP] Re: Date validation

2011-05-23 Thread Pete Ford
On 20/05/11 16:29, Geoff Lane wrote: On Friday, May 20, 2011, Peter Lind wrote: Try: $date = new DateTime($date_string_to_validate); echo $date->format('Y-m-d'); Many thanks. Unfortunately, as I mentioned in my OP, the DateTime class seems to be 'broken' for my purposes because it uses str

[PHP] Re: Date validation

2011-05-21 Thread Geoff Lane
I'm posting here for completeness as I've now rolled my own date validator (code follows my sig). It allows almost all valid 'English' formats except ordinal day values (1st, 3rd, etc.) Because I'm in UK and writing for a UK audience, I've parsed ambiguous dates as d/m/y. Those writing for places w

[PHP] Re: Date validation

2011-05-20 Thread Geoff Lane
On Friday, May 20, 2011, João Cândido de Souza Neto wrote: > What about using regular expression to validate so using DateTime > object to parse it if it?s a valid date? Again, thanks. For info, I only need to know that it's a valid representation of a date on this occasion as I intend to use

[PHP] Re: Date validation

2011-05-20 Thread Geoff Lane
On Friday, May 20, 2011, Peter Lind wrote: > Try: > $date = new DateTime($date_string_to_validate); > echo $date->format('Y-m-d'); Many thanks. Unfortunately, as I mentioned in my OP, the DateTime class seems to be 'broken' for my purposes because it uses strtotime() to convert input strings to

Re: [PHP] Re: Date validation

2011-05-20 Thread Peter Lind
On 20 May 2011 16:47, Geoff Lane wrote: *snip* >>> Also, AFAICT createFromFormat fails if the date is not formatted >>> according to the first parameter. So, for example: >>>  $date = DateTime::createFromFormat('d M Y', '5/2/10') >>> fails ... (at least, it does on my system :( ) >>> > >> I'm s

[PHP] Re: Date validation

2011-05-20 Thread Jo�o C�ndido de Souza Neto
What about using regular expression to validate so using DateTime object to parse it if it?s a valid date? -- João Cândido de Souza Neto "Geoff Lane" escreveu na mensagem news:574766433.20110520154...@gjctech.co.uk... On Friday, May 20, 2011, Peter Lind wrote: >> This is pretty much as exp

[PHP] Re: Date validation

2011-05-20 Thread Geoff Lane
On Friday, May 20, 2011, Peter Lind wrote: >> This is pretty much as expected except that the second call to >> date() - i.e. date('d M Y', $date) - outputs nothing. > date() takes an int as second parameter - a timestamp. Not an object. > And from a quick test it doesn't look like DateTime has

Re: [PHP] Re: Date validation

2011-05-20 Thread Peter Lind
2011/5/20 João Cândido de Souza Neto : > If you look carefully, you´ll notice that I´m using the DateTime object > (default from PHP 5.2.0 or higher) not the function date. If you look carefully, you'll notice that I replied to Geoff. Regards Peter -- WWW: plphp.dk / plind.dk LinkedIn: pli

Re: [PHP] Re: Date validation

2011-05-20 Thread Jo�o C�ndido de Souza Neto
If you look carefully, you´ll notice that I´m using the DateTime object (default from PHP 5.2.0 or higher) not the function date. -- João Cândido de Souza Neto "Peter Lind" escreveu na mensagem news:banlktinjonyvfnqjqtfqtdmu_r2-cfp...@mail.gmail.com... On 20 May 2011 16:22, Geoff Lane wr

Re: [PHP] Re: Date validation

2011-05-20 Thread Peter Lind
On 20 May 2011 16:22, Geoff Lane wrote: >  On Friday, May 20, 2011, João Cândido de Souza Neto wrote: > >> What about using this: > >> $date = DateTime::createFromFormat("Y-m-d", "2011-05-20"); > > Hi João, and thanks for your help. > > FWIW, I thought about that but it didn't work for me. On

[PHP] Re: Date validation

2011-05-20 Thread Geoff Lane
On Friday, May 20, 2011, João Cândido de Souza Neto wrote: > What about using this: > $date = DateTime::createFromFormat("Y-m-d", "2011-05-20"); Hi João, and thanks for your help. FWIW, I thought about that but it didn't work for me. On further investigation, I'm now completely confused and

[PHP] Re: Date validation

2011-05-20 Thread Jo�o C�ndido de Souza Neto
What about using this: $date = DateTime::createFromFormat("Y-m-d", "2011-05-20"); -- João Cândido de Souza Neto "Geoff Lane" escreveu na mensagem news:11565581.20110520132...@gjctech.co.uk... > Hi All, > > I'm scratching my head trying to remember how I validated string > representation of

[PHP] Re: Date Validation, Kinda'

2003-08-21 Thread Scott Fletcher
I did similiar posting about finding the last day of the month last week and got some response. So, I'll just post some clipping from php.net for you. If your machine support the php mktime() then you're in for luck. You can find more info about it at php.net with the function, date() and mktime(