Extra contribution to nette/utils
.
There are many classes in this package. Almost all are extending from nette/utils
and adding more functionality.
composer require contributte/utils
This extension register simple DateTime
provider -> DateTimeFactory
.
extensions:
datetime: Contributte\Utils\DI\DateTimeFactoryExtension
You can use the default or override it by our own implementation:
services:
datetime.factory: App\Model\MyDateTimeFactory
Another useful methods added to DateTime
:
setCurrentTime()
setZeroTime() && resetTime()
setMidnight()
setToday()
getFirstDayOfWeek()
getLastDayOfWeek()
getFirstDayOfMonth()
getLastDayOfMonth()
getFirstDayOfYear()
getLastDayOfYear()
Collections of functions for normalizing input:
inn($s)
tin($s)
zip($s)
phone($s)
Collection of extra functions:
pathalize($path)
extension($file)
purge($dir)
Collection of extra functions:
replacePrefix($s, $search, $replacement = '')
replaceSuffix($s, $search, $replacement = '')
spaceless($s)
doublespaceless($s)
dashless($s)
slashless($s)
Collection of extra functions:
hasFragment($url)
Collection of extra functions:
isIco($s)
- trader identification number (Czech only)isRc($s)
- personal identification number (Czech and Slovak only)
Collection of extra functions:
metadata($s)
- gets http metadata from string, returns as[name => content]