You are here: Re: Date validation issue « PHP Programming Language « IT news, forums, messages
Re: Date validation issue

Posted by Alvaro G Vicario on 06/27/05 13:00

*** ndsoumah@gmail.com wrote/escribió (26 Jun 2005 21:04:47 -0700):
> 1- convert the input string into date first. At this point I couldn't
> find any srtTOdate type of functions.

In the "Date and Time Functions" chapter of the PHP manual you have all
date and time functions, including strtotime()


then I tried doing it the hard
> way...by using "checkdate" function. I could split the string fine
> (using "explode") but then I was stuck because I couldn't find any
> function to convert a string into Integer!
>
> 2- I need to check if the date is valid

As you already mentioned, checkdate sounds like a good option.


You may also find useful this code for a previous additional client-side
validation:

/*
* Returns true if valid date, false otherwise
* Month range is [1,12]
*/
function is_date(day, month, year // v2005-03-14
var TheDate=new Date();
TheDate.setFullYear(year, month-1, day);

return (TheDate.getDate()==day) && (TheDate.getMonth()==month-1) &&
(TheDate.getFullYear()==year);
}


--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация