I'm developing a zend form for a events. I wanna validate two dates such that the first one ($date_start
) should be greater than the current date and the second one ($date_end
) should be greater than the first one ($date_end > $date_start
). Does anybody knows how to do it using validators?
Asked
Active
Viewed 4,796 times
1

José Carlos
- 1,005
- 16
- 29
-
1Have you read this? http://framework.zend.com/manual/en/zend.validate.writing_validators.html – vascowhite Aug 01 '11 at 05:38
-
just a little comment to say that you can use comparaison operators `<` and `>` on datetimes in PHP. Maybe this can help. – julesbou Aug 01 '11 at 09:44
2 Answers
4
Easy with Zend Date
$dateOne = new Zend_Date(time());
$dateTwo = new Zend_Date(time());
if ($dateOne->isLater($dateTwo)) {
// do what ever
}
if ($dateOne->isEarlier($dateTwo)) {
// do what ever
}

opHASnoNAME
- 20,224
- 26
- 98
- 143
1
Yes what @ArnieRie says is right .
But as you are looking to use in Zend_Form
You can check this question : Zend Form Validate Range Date
Same applies here. I saw the same article over http://www.oplabo.com/article/22 .