Categorie PHP Tutorials Howto detect if typed date is valid Autore articolo Di Diego La Monica Data dell'articolo 30 Agosto 2012 6 commenti su Howto detect if typed date is valid This simple tip allow you to detect if the date is typed correctly and the date format is as expected. Share:TweetWhatsAppMi piace Caricamento... Correlati Tag date, leap year, validation ← ALPHA Framework: Storage 1.2 … What’s new? → Ubuntu aggiornamento 11.10 su Acer Aspire 5738ZG 6 risposte su “Howto detect if typed date is valid” Riddle: catch the bug. isValidDate('30/08/2012', '/', 'dmy') == true isValidDate('29/02/2000', '/', 'dmy') == true isValidDate('10/10/1580', '/', 'dmy') == true isValidDate('29/02/2001', '/', 'dmy') == false isValidDate('10/10/1582', '/', 'dmy') == true isValidDate('10/12/2121', '/', 'dmy') == true isValidDate('10/10/2000', '/', 'dmy') == true where is the function lack? Caricamento... Hi Giacomo, trying the following code: Hi Giacomo, trying the following code: var_dump(validaData('30/08/2012', '/', 'dmy')); # bool(true) var_dump(validaData('29/02/2000', '/', 'dmy')); # bool(true) var_dump(validaData('10/10/1580', '/', 'dmy')); # bool(true) var_dump(validaData('29/02/2001', '/', 'dmy')); # bool(false) var_dump(validaData('10/10/1582', '/', 'dmy')); # bool(true) var_dump(validaData('10/12/2121', '/', 'dmy')); # bool(true) var_dump(validaData('10/10/2000', '/', 'dmy')); # bool(true) the output is as expected. So… where is the bug? :) Caricamento... Think: which was the day after 4th October 1582 ? Caricamento... It was the October, 5th 1582, not? :) Caricamento... no, it wasn’t! the day after 4th october, was 15th october, according to Gregorian calendar. ….but …. …but…. there are many consideration we could do. (i.e. Swedish Reign used Giulian (Assange) calendar till 1699) Caricamento... touche! :) Thanks Giacomo! As you can notice, I’ve changed the script. Caricamento... I commenti sono chiusi
Riddle: catch the bug. isValidDate('30/08/2012', '/', 'dmy') == true isValidDate('29/02/2000', '/', 'dmy') == true isValidDate('10/10/1580', '/', 'dmy') == true isValidDate('29/02/2001', '/', 'dmy') == false isValidDate('10/10/1582', '/', 'dmy') == true isValidDate('10/12/2121', '/', 'dmy') == true isValidDate('10/10/2000', '/', 'dmy') == true where is the function lack? Caricamento...
Hi Giacomo, trying the following code: Hi Giacomo, trying the following code: var_dump(validaData('30/08/2012', '/', 'dmy')); # bool(true) var_dump(validaData('29/02/2000', '/', 'dmy')); # bool(true) var_dump(validaData('10/10/1580', '/', 'dmy')); # bool(true) var_dump(validaData('29/02/2001', '/', 'dmy')); # bool(false) var_dump(validaData('10/10/1582', '/', 'dmy')); # bool(true) var_dump(validaData('10/12/2121', '/', 'dmy')); # bool(true) var_dump(validaData('10/10/2000', '/', 'dmy')); # bool(true) the output is as expected. So… where is the bug? :) Caricamento...
no, it wasn’t! the day after 4th october, was 15th october, according to Gregorian calendar. ….but …. …but…. there are many consideration we could do. (i.e. Swedish Reign used Giulian (Assange) calendar till 1699) Caricamento...
6 risposte su “Howto detect if typed date is valid”
Riddle: catch the bug.
where is the function lack?
Hi Giacomo,
trying the following code:
Hi Giacomo,
trying the following code:
the output is as expected. So… where is the bug? :)
Think: which was the day after 4th October 1582 ?
It was the October, 5th 1582, not? :)
no, it wasn’t!
the day after 4th october, was 15th october, according to Gregorian calendar.
….but ….
…but…. there are many consideration we could do. (i.e. Swedish Reign used Giulian (Assange) calendar till 1699)
touche! :)
Thanks Giacomo! As you can notice, I’ve changed the script.