nette-utilslisted
Install: claude install-skill nette/agent-plugins
## Nette Utils
A collection of useful PHP utility classes for everyday tasks.
```shell
composer require nette/utils
```
For detailed references:
- [Arrays, ArrayHash, ArrayList](references/arrays.md)
- [Strings and regex functions](references/strings.md)
- [Image manipulation](references/image.md)
- [File searching with Finder](references/finder.md)
---
## DateTime
Extended `DateTime` class with strict validation and DST fixes. There is also
`Nette\Utils\DateTimeImmutable` (since 4.1.5) with the same API on top of
`\DateTimeImmutable` — **prefer it for new code**, mutable date objects are a classic source of
action-at-a-distance bugs.
```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($dat