date checking doubt

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
avmohankumar
Forum Newbie
Posts: 14
Joined: Fri Jun 08, 2007 7:20 am

date checking doubt

Post by avmohankumar »

Dear,

If, instead of 13-01-2003, the user writes 13/01/2003, the system must show an error message.
If, instead of 13-01-2003, the user writes 13-01-03, the system must show an error message.
If, instead of 13-01-2003, the user writes 2003-01-13, the system must show an error message.
And so on…

The error message could be something like:
“Attention! The inserted date is not in the correct format.”

if we enter in one text bow the date, it should check the date.

how i can resolve this, please help me.

Regards,
avmohan
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Split the string on "-"
show an error message if
- the resulting array does not have exactly 3 elements
- the last element does not have exactly 4 digits
- checkdate() returns false

see http://php.net/explode and http://php.net/checkdate
avmohankumar
Forum Newbie
Posts: 14
Joined: Fri Jun 08, 2007 7:20 am

thank you

Post by avmohankumar »

Dear,

Thank you very much,

I will proceed the things as you said, thanks a lot.

Regards,
avmohan
Post Reply