1. Go to this page and download the library: Download zogot/constraints-date library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
zogot / constraints-date example snippets
Zogo\DateConstraints\Constraints\Day\DayConstraintInterface;
use Zogo\DateConstraints\Constraints\Day\SpecificDayConstraint;
use Zogo\DateConstraints\Constraints\Month\MonthConstraintInterface;
use Zogo\DateConstraints\Constraints\Month\SpecificMonthConstraint;
use Zogo\DateConstraints\Validators\AndValidator;
// Build a validator instance
$validator = new AndValidator();
// Add constraints to that validator
$validator
->addConstraint(new SpecificDayConstraint(DayConstraintInterface::TUESDAY))
->addConstraint(new SpecificMonthConstraint(MonthConstraintInterface::FEBRUARY))
// Attempt a datetime
$validator->validFor(new DateTime('Tuesday, 16 Feb 2016 13:00:00 GMT')) // true
$validator->validFor(new DateTime('Monday, 15 Feb 2016 13:00:00 GMT')) // false
// Build the validator instance
$validator = new AndValidator();
// Add Constraints to that validator
$validator
->addConstraint(new BetweenTimeConstraint(new DateTime('09:00:00'), new DateTime('17:00:00'))
// Attempt a datetime
$validator->validFor(new DateTime('Tuesday, 16 Feb 2016 13:00:00 GMT')) // true
$validator->validFor(new DateTime('Tuesday, 16 Feb 2016 18:00:00 GMT')) // false
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.