papimod / date
Module Papi
Installs: 5
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/papimod/date
Requires
- php: >=8.3.0
- papi/papi: ^2.1.0
- papimod/dotenv: ^2.1.0
Requires (Dev)
- phpunit/phpunit: ^12.4
- squizlabs/php_codesniffer: ^4.0
This package is auto-updated.
Last update: 2025-12-29 14:14:27 UTC
README
Description
Help defining the API date format with time zone in your papi.
Also provide a DateService class to convert dates.
Prerequisites Modules
Configuration
DATE_FORMAT (.ENV)
| Required | No |
| Type | string |
| Description | Global date format |
| Default | Y-m-d |
DATE_TIME_FORMAT (.ENV)
| Required | No |
| Type | string |
| Description | Global time format |
| Default | H:i:s |
DATE_TIMEZONE (.ENV)
| Required | No |
| Type | string |
| Description | Global timezone |
| Default | Europe/Paris |
Definitions
Usage
You can add the following options to your .env file:
DATE_FORMAT="Y-m-d"
DATE_TIME_FORMAT="H:i:s"
DATE_TIMEZONE="Europe/Paris"
Import the module when creating your application:
require __DIR__ . "/../vendor/autoload.php"; use Papi\PapiBuilder; use Papimod\Dotenv\DotEnvModule; use Papimod\Date\DateModule; use function DI\create; $builder = new PapiBuilder(); $builder->setModule( DotEnvModule::class, DateModule::class ) ->build() ->run();
Use the dedicated service anywhere:
final class MyService { public function __construct(public readonly DateService $date_service) { } public getNow(): string { $now = new DateTime(); return $this->date_service->format($now); } }