papimod/date 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

papimod/date

最新稳定版本:v2.1.1

Composer 安装命令:

composer require papimod/date

包简介

Module Papi

README 文档

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);
    }
}

统计信息

  • 总下载量: 5
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2025-12-07