illchuk / time-normalize
A basic validator and filter for time input.
v0.1.1
2017-10-26 16:38 UTC
Requires
- php: ^5.5|^7.0
- zendframework/zend-inputfilter: ^2.0
- zendframework/zend-validator: ^2.0
Requires (Dev)
- phpunit/phpunit: ~4.0
This package is auto-updated.
Last update: 2025-02-08 10:08:57 UTC
README
A basic validator and filter for time input.
Installation
Install with composer require illchuk/time-normalize
.
You may install in your ZendFramework app by adding to your modules.config.php
the following:
return [..., 'TimeNormalize' ,...]; // validator and filter both called 'Time'
Or use in a direct fashion:
use TimeNormalize\Validator\Time as TimeValidator;
use TimeNormalize\Filter\Time as TimeFilter;
$validator = new TimeValidator;
echo $validator->isValid('12:34am'); // true
echo $validator->isValid('12:34jm'); // false
$filter = new TimeFilter;
echo $filter->filter('12:34 am'); // '00:34'
echo $filter->filter('12:34 pm'); // '12:34'
echo $filter->filter('junk'); // 'junk'