Provides Nette Utils helper classes. Use when working with arrays, strings, files, images, JSON, validators, DateTime, or other utility functions.
View on GitHubnette/claude-code
nette
January 20, 2026
Select agents to install to:
npx add-skill https://github.com/nette/claude-code/blob/main/plugins/nette/skills/nette-utils/SKILL.md -a claude-code --skill nette-utilsInstallation paths:
.claude/skills/nette-utils/## Nette Utils
A collection of useful PHP utility classes for everyday tasks.
```shell
composer require nette/utils
```
For detailed references:
- [arrays.md](arrays.md) - Arrays, ArrayHash, ArrayList
- [strings.md](strings.md) - Strings and regex functions
- [image.md](image.md) - Image manipulation
- [finder.md](finder.md) - File searching
---
## DateTime
Extended `DateTime` class with strict validation and DST fixes.
```php
use Nette\Utils\DateTime;
// Create from various formats
DateTime::from(1138013640); // from timestamp
DateTime::from('2024-02-26 04:15:32'); // from string
DateTime::from($dateTimeInterface); // from object
// Create from parts (throws on invalid date)
DateTime::fromParts(2024, 2, 26, 4, 15);
// Immutable modification
$clone = $original->modifyClone('+1 day');
// Convert relative time to seconds
DateTime::relativeToSeconds('10 minutes'); // 600
DateTime::relativeToSeconds('-1 hour'); // -3600
// JSON serialization (ISO 8601)
echo json_encode($dateTime); // "2024-02-26T04:15:32+01:00"
```
---
## Json
Safe JSON encoding/decoding with exceptions.
```php
use Nette\Utils\Json;
// Encode
$json = Json::encode($data);
$json = Json::encode($data, pretty: true); // formatted
$json = Json::encode($data, asciiSafe: true); // escape unicode
$json = Json::encode($data, htmlSafe: true); // escape < > &
$json = Json::encode($data, forceObjects: true); // arrays as objects
// Decode
$data = Json::decode($json); // returns stdClass
$data = Json::decode($json, forceArray: true); // returns array
// Both throw Nette\Utils\JsonException on error
```
---
## Validators
Value validation and type checking.
```php
use Nette\Utils\Validators;
// Type checking
Validators::is($value, 'int'); // true/false
Validators::is($value, 'int|string|bool'); // union types
Validators::is($value, 'int:0..100'); // range
Validators::is($value, 'string:10..20'); // length range