| Package Data | |
|---|---|
| Maintainer Username: | lynnlin | 
| Maintainer Contact: | lynn80827@hotmail.com (Lynn Lin) | 
| Package Create Date: | 2016-04-08 | 
| Package Last Update: | 2016-08-09 | 
| Home Page: | https://packagist.org/packages/lynnlin/date-time-validator | 
| Language: | PHP | 
| License: | MIT | 
| Last Refreshed: | 2025-10-25 15:02:07 | 
| Package Statistics | |
|---|---|
| Total Downloads: | 12 | 
| Monthly Downloads: | 0 | 
| Daily Downloads: | 0 | 
| Total Stars: | 2 | 
| Total Watchers: | 1 | 
| Total Forks: | 1 | 
| Total Open Issues: | 0 | 
Add a new validation rule during to validate whether the given date time is in a specific period which is 6 months by default.
Install the package via composer.
composer require lynnlin/date-time-validator
Add the service provider into config/app.php.
'providers' => [
	...
	DateTimeValidator\ValidatorServiceProvider::class,
	...
]
use Illuminate\Support\Facades\Validator;
// check 20160123 whether it is in 6 months ago from today
Validator::make(
    ['startAt' => '20160123'],
    ['startAt' => 'during']
);
// check 20150123 whether it is in 1 year ago from today since endAt is not given in the first argument
Validator::make(
    ['startAt' => '20150123'],
    ['startAt' => 'during:endAt,1Y', 'endAt' => 'string']
);
// check 20150123 whether it is in 1 day from 20150124
Validator::make(
    ['startAt' => '20150123', 'endAt' => '20150124'],
    ['startAt' => 'during:endAt,1d', 'endAt' => 'string']
);
// check 20150123 whether it is in 1 week from 20150124
Validator::make(
    ['startAt' => '20150123', 'endAt' => '20150124'],
    ['startAt' => 'during:endAt,1w', 'endAt' => 'string']
);