José Carlos
José Carlos

Reputation: 1015

Validating dates in zend framework (comparing two)

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?

Upvotes: 1

Views: 4822

Answers (2)

Hari K T
Hari K T

Reputation: 4254

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 .

Upvotes: 1

opHasNoName
opHasNoName

Reputation: 20736

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
}

Upvotes: 4

Related Questions